adding multiple pins on google map in ios

旧时模样 提交于 2019-12-01 09:30:14

This works for me:

for(GMSMarker*marker in array)
    {
        GMSMarker *mkr= [[GMSMarker alloc]init];
        [mkr setPosition:CLLocationCoordinate2DMake(<coord>)];

        [mkr setAnimated:YES];
        [mkr setTitle:<Title>];
        [mkr setSnippet:<Snippet>];
        [mkr setMap:mapView_];
    }

Using latest Google Maps SDK.

Hope it helps

self.view = mapView_;     
for(int i=0;i<[array count];i++)
{       
   GMSMarker *marker = [[GMSMarker alloc] init];
   marker.animated=YES;
   marker.position = CLLocationCoordinate2DMake(latitude,longitude);
   marker.title = @"name";
   marker.snippet = @"snippet";
   marker.map = mapView_;
}

This worked for me!

For swift we can use

for i in 0..<array.count() {
    var marker = GMSMarker()
    marker.animated = true
    marker.position = CLLocationCoordinate2DMake(latitude, longitude)
    marker.title = "name"
    marker.snippet = "snippet"
    marker.map = mapView_
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!