简体   繁体   中英

Move a GMSPolyline in iOS

I have a requirement that in some cases a GMSPolyline be moved from one location to another. Here is the scenario:

  1. A user opens a GMSMapView and creates a GMSPolyline feature.
  2. Then the user changes the map position
  3. The user taps a button to center the newly created polyline in the new view position, that is, the newly created line feature is moved to the center of the new camera view.

So far I can find no resources for how to do this. There are plenty of examples for creating and editing GMSPolyline features, but not finding one for moving the entire feature. Can anyone point me to an example for doing this?

Thanks!

You have to change the coordinates of all the locations that make the GSMPath that is the base of your GMSPolyline. For each location you can calculate the new point using GMSGeometryOffset , then you draw a new polyline.

Or you can use -(instancetype) pathOffsetByLatitude:longitude: of GMSPath on the GMSPath that describes your polyline.

You use one or the other according the data that you have available (as an example the start and end target of the GMSCameraPosition after a pan)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM