Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS google maps sdk GMSMarker positioning

I am working with Google maps and I am able to center the map to the GMSMarker by using

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

I am showing a custom callout of size 200*150 and part of it gets hidden when the camera position is changed but I want the callout to be in the center and the map point to be below it. Any ideas how to do this.

like image 385
Satheesh Avatar asked May 22 '13 08:05

Satheesh


1 Answers

Have a look at using GMSProjection. To shift the center of the map 100px from the markers location you would do something like:

- (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;
}
like image 167
skarE Avatar answered Oct 13 '22 09:10

skarE