1

I'm able to draw GMSPolyline on GoogleMaps with array of locations like this

GMSMutablePath *path = [GMSMutablePath path];

    for (int i = 0; i <anotherArray.count; i++) {

        NSString *string1 = [anotherArray2 objectAtIndex:i];
        NSString *string2 = [anotherArray objectAtIndex:i];
        [path addCoordinate:CLLocationCoordinate2DMake(string1.doubleValue,string2.doubleValue)];
    }

        GMSPolyline *rectangle = [GMSPolyline polylineWithPath:path];
        rectangle.strokeColor = [UIColor blueColor];
        rectangle.map = mapView_;
        rectangle.strokeWidth = 2.0f;

But the locations I'm getting from backend server.

So I have to refresh every 10 seconds,getting new locations and adding it to existing path. These are all working fine.

But when I am adding new locations to existing path is moving very fast.

Cause I have a GMSMarker at starting of path and it is looking like jumping from one place to another place.

So how can I animate GMSMarker like slowly moving from one place to another place?

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
Himanth
  • 2,381
  • 3
  • 28
  • 41

1 Answers1

0

Check on this tutorial. It states how to draw the route lines on the map using the GMSPolyline class. From this related SO thread:

Change your else block to be something more like this:

[CATransaction begin];
[CATransaction setAnimationDuration:2.0];
marker.position = coordindates;
[CATransaction commit];

We enable you to use Core Animation for animating Google Maps.

For a worked sample, please see AnimatedCurrentLocationViewController.{c,m} in the SDK sample application.

Also based from this SO post, avoid using 1px stroke-width of line. Instead, use 4px stroke-width. You can also check on this GitHub sample.

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59