如何通过网络请求中使用谷歌 iOS SDK 显示多个标记



我是iOS编程的新手。我一直在研究需要通过坐标(谷歌 iOS SDK)在地图上获取和显示多个标记的项目。我按照本教程在地图中创建标记。

我可以使用NSLOG获得响应。我想要的是在地图上打印这些坐标。请给我一个明确的例子 Objective-c.

根据这里的问题,您可以在 for 循环的帮助下使用多个标记,如下所示。

NSArray *arrLatLong; // Get it from your response
for(NSDictionary *dictLocation in arrLatLong){
    GMSMarker *marker1 = [[GMSMarker alloc] init];
    marker1.position = CLLocationCoordinate2DMake(dictLocation[@"latitude"].doubleValue,dictLocation[@"longitude"].doubleValue);
    marker1.title = @"Lake Eola";
    marker1.snippet = @"Come see the swans";
    marker1.appearAnimation = kGMSMarkerAnimationPop;
    marker1.icon = [GMSMarker markerImageWithColor:[UIColor greenColor]];
    //Assign that marker to your current MapView
    marker1.map = self.mapView;
}

在从服务器获得响应后使用此选项。

希望这对您有所帮助。

最新更新