2013-05-22 90 views
9

我与谷歌地图的工作,我能够通过使用iOS版谷歌地图SDK GMSMarker定位

GMSCameraPosition *camera = 
    [[GMSCameraPosition alloc] initWithTarget:marker.position 
             zoom:MAP_ZOOM_LEVEL 
             bearing:0 
           viewingAngle:0]; 
    [mapView animateToCameraPosition:camera]; 

我显示尺寸的定制标注200 * 150和部分的它在地图中间的GMSMarker当相机位置改变时会隐藏,但我希望标注位于中心,地图点位于其下方。任何想法如何做到这一点。

回答

17

看看使用GMSProjection

- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker { 
    CGPoint point = [mapView_.projection pointForCoordinate:marker.position]; 
    point.x = point.x + 100; 
    GMSCameraUpdate *camera = 
     [GMSCameraUpdate setTarget:[mapView_.projection coordinateForPoint:point]]; 
    [mapView_ animateWithCameraUpdate:camera]; 
    return YES; 
} 
+0

我想这一点,但地图中心本身与所述标记物:从标记的位置,你会做类似移动地图100像素的中心中点。 – satheeshwaran

+0

是的,这就是我写的代码。你需要修改point.x和point.y,使其成为你想要的偏移量。 – skarE

+0

我对x和y都加了1000,同样的事情发生了。 – satheeshwaran

2

斯威夫特4,3

​​