iOS google maps sdk GMSMarker positioning

前端 未结 2 1931
暖寄归人
暖寄归人 2020-12-11 15:56

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

 GMSCameraPosition *camera =
    [[GMSCameraPosition alloc] initWithT         


        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-11 16:23

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

提交回复
热议问题