【问题标题】:How to add pin on Google Map when location is changed in ios在ios中更改位置时如何在Google Map上添加图钉
【发布时间】:2014-03-04 13:40:15
【问题描述】:

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

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

【问题讨论】:

    标签: ios iphone google-maps


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2013-11-08
      • 1970-01-01
      • 2022-11-11
      • 1970-01-01
      • 1970-01-01
      • 2016-08-04
      • 2015-12-01
      • 2011-04-26
      • 1970-01-01
      相关资源
      最近更新 更多