如何在拖动后检测标记的位置

时间:2015-12-31 04:28:58

标签: objective-c google-maps-markers google-maps-sdk-ios

我试图在Google Map中拖拽之后获得Marker的位置。目前我可以根据片段中设备的当前位置在Google Map中添加Marker。现在,我想要的是尝试根据可拖动的位置获得Marker的位置。

placemark = [placemarks lastObject];
CLLocationCoordinate2D position = { [latitude doubleValue], [longitude doubleValue] };
mymarker = [GMSMarker markerWithPosition:position];
mymarker.title = [NSString stringWithFormat:@"%@", placemark.thoroughfare];
mymarker.appearAnimation = YES;
mymarker.flat = YES;
mymarker.snippet = [NSString stringWithFormat:@"%@ %@, %@ %@", placemark.locality, placemark.administrativeArea, placemark.postalCode, placemark.country];
mymarker.map = _mapView;
mymarker.draggable = true;

1 个答案:

答案 0 :(得分:0)

试一试

-(void)mapView:(GMSMapView *)mapView didEndDraggingMarker:(GMSMarker *)marker{
        NSLog(@"New location of marker: Lat: %f, Long: %f", marker.position.latitude, marker.position.longitude);
}