user4246509
user4246509

Reputation:

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 !

Upvotes: 2

Views: 1234

Answers (2)

Bharat
Bharat

Reputation: 340

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.

Upvotes: 0

Ekta Padaliya
Ekta Padaliya

Reputation: 5799

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_;

Upvotes: 7

Related Questions