在ios上的谷歌地图上添加多个引脚 [英] adding multiple pins on google map in ios

查看:211
本文介绍了在ios上的谷歌地图上添加多个引脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在谷歌地图上添加多个引脚,当它正在加载时。

I want to add multiple pins on a google map, while it is being loaded.

我有一个附近位置的纬度和经度值列表。
如何使用别针在地图上显示所有这些位置。我正在使用适用于iOS的Google SDK。

I have a list of Latitude and Longitude values of nearby locations. How can I show all these locations on the map with a pin. I am using Google SDK for iOS.

我使用以下代码,但它对我不起作用。

I am using the following code, but it didn't work for me.

NSMutableArray *array = [NSMutableArray arrayWithObjects:@"12.981902,80.266333",@"12.982902,80.266363", nil];

CLLocationCoordinate2D pointsToUse[5];

for (int i = 0; i < [array Size]; i++)
{
    pointsToUse[i] = CLLocationCoordinate2DMake([[[[array objectAtIndex:0]  componentsSeparatedByString:@","] objectAtIndex:0] floatValue],[[[[array objectAtIndex:0]  componentsSeparatedByString:@","] objectAtIndex:1] floatValue]);

    [array removeObjectAtIndex:0];

    GMSMarkerOptions *options = [[GMSMarkerOptions alloc] init];
    options.position = pointsToUse[i];
    [mapView_ animateToLocation:pointsToUse[i]];
    [mapView_ addMarkerWithOptions:options];
}

我已经尝试过搜索它但是没有足够的文档来回答我的问题。

I have tried enough to search for it but there isn't enough documentation to answer my question.

提前感谢您的帮助。

推荐答案

这对我有用:

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

使用最新的Google Maps SDK。

Using latest Google Maps SDK.

希望有帮助

这篇关于在ios上的谷歌地图上添加多个引脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆