iOS Google地图:协调不匹配

时间:2015-10-13 09:32:33

标签: ios iphone google-maps

我们的应用程序的一个功能是在地图上绘制一个位置,我们将其保存在我们的服务器中并将其显示在应用程序的主屏幕上。我们正在使用Google地图和GMSMarker,其draggable属性设置为YES。但是标记的位置和获得的坐标之间存在差异。

代码:

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

Sample result

我是否遗漏了代码或其他内容?请建议解决方案或解决方法以解决此问题。谢谢!

测试环境

  • xCode - 7.0
  • Google Maps SDK版本 - 1.10.3(使用pod)
  • 设备 - iPhone 5S,iPhone 6plus
  • iOS - 9.0.2

0 个答案:

没有答案
相关问题