简体   繁体   中英

Draw Straight Line Google Maps iOS

hey everyone I'm working on an iOS app and I integrated Google Maps API and I'm using Objective C

I implemented a function that put marks on the maps for every touch to the screen + I get the longitude and latitude of that mark

I want to draw straight lines between those marks, every time I add a new mark it should be linked with the one before

Any ideas please !

GMSMutablePath *path = [GMSMutablePath path];
[path addCoordinate:CLLocationCoordinate2DMake(37.36, -122.0)];
[path addCoordinate:CLLocationCoordinate2DMake(37.45, -122.0)];

GMSPolyline *line = [GMSPolyline polylineWithPath:path];
line.map = mapView_;

In addition to Ekta's answer: If you want to change the line when your Marker is dragged, you just need to follow these steps:

  • Clear your map using [mapview clear];
  • Redraw the line using directions given by Ekta.

Hope it helps.

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