iOS谷歌地图:坐标不匹配
我们的应用程序的一个特性是在地图上绘制一个位置,我们将它保存在服务器中,并在应用程序的主屏幕上显示。我们使用的是谷歌地图和GMSMarker,draggable属性设置为YES。但标记位置与获得的坐标之间存在差异 代码:iOS谷歌地图:坐标不匹配,ios,iphone,google-maps,Ios,Iphone,Google Maps,我们的应用程序的一个特性是在地图上绘制一个位置,我们将它保存在服务器中,并在应用程序的主屏幕上显示。我们使用的是谷歌地图和GMSMarker,draggable属性设置为YES。但标记位置与获得的坐标之间存在差异 代码: NSDictionary *signDict = self.imgLocationsArray[_currentIndex]; _toSaveLat = [signDict[TAG_SIGN_LAT
NSDictionary *signDict = self.imgLocationsArray[_currentIndex];
_toSaveLat = [signDict[TAG_SIGN_LAT] floatValue];
_toSaveLon = [signDict[TAG_SIGN_LONG] floatValue];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:_toSaveLat longitude:_toSaveLon zoom:GOOGLE_MAPS_DEFAULT_ZOOM_LEVEL];
self.dragDropMap = [GMSMapView mapWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) camera:camera];
[self.dragDropMap setMapType:kGMSTypeNormal];
[self.dragDropMap setDelegate:self];
self.dragDropMap.myLocationEnabled = YES;
[self.view addSubview:self.dragDropMap];
if (draggingMarker) {
draggingMarker.map = nil;
draggingMarker = nil;
}
draggingMarker = [[GMSMarker alloc] init];
draggingMarker.icon = [GMSMarker markerImageWithColor:[UIColor plumColor]];//[UIImage imageNamed:@"MoveablePin"];
draggingMarker.position = CLLocationCoordinate2DMake(_toSaveLat, _toSaveLon);
draggingMarker.tappable = NO;
draggingMarker.draggable = YES;
draggingMarker.map = self.dragDropMap;
-(void)mapView:(GMSMapView *)mapView didEndDraggingMarker:(GMSMarker *)marker{
NSLog(@"marker dragged to location: %f,%f", marker.position.latitude, marker.position.longitude);
_toSaveLat = marker.position.latitude;
_toSaveLon = marker.position.longitude;
}
我是不是在代码中遗漏了什么?请建议一个解决方案或解决方法来修复此问题。谢谢
测试环境
- xCode-7.0
- 谷歌地图SDK版本-1.10.3(使用pod)
- 设备-iPhone 5S、iPhone 6plus
- iOS-9.0.2