如何在ios中更改位置时在Google地图上添加图钉

时间:2014-03-04 13:40:16

标签: ios iphone google-maps

我使用谷歌地图。添加第一个时间引脚,当位置改变时,引脚被覆盖,最后一个引脚。我想在每次更改位置时在位置上添加新引脚。 所以任何人都可以帮助我。

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations

{

location_updated = [locations lastObject];

NSLog(@"updated coordinate are %@",location_updated);

latitude1 = location_updated.coordinate.latitude;

longitude1 = location_updated.coordinate.longitude;


NSLog(@"%f,%f",latitude1, longitude1);
self.lblLat.text = [NSString stringWithFormat:@"%f",latitude1];
self.lblLon.text = [NSString stringWithFormat:@"%f",longitude1];

url = [NSURL URLWithString:[NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f&sensor=false",latitude1,longitude1]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
connection = [NSURLConnection connectionWithRequest:request delegate:self];
if (connection)
{
    webData1 = [[NSMutableData alloc]init];

}

    GMSMarker *marker = [[GMSMarker alloc] init];
    marker.position = CLLocationCoordinate2DMake(latitude1,longitude1);
    marker.title = @"Ahmedabad";
    marker.snippet = @"India";
    marker.icon = [UIImage imageNamed:@"m2.png"];
    marker.map = mapView_;
}

1 个答案:

答案 0 :(得分:0)

您可以使用ios 7中的此updateLocation方法实现此目的。

并且要添加多个标记,您必须使用GMSMarker类。

相关问题