I want to use Scale controls in the google map for iOS,but I found nothing in the document of google map SDK for iOS about scale controls.Is there a Scale Controls in google map SDK for iOS ?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You need to use zoom levels in GMSCameraPosition by providing lang, lat values.
GMSCameraPosition Class Reference
- (float) zoom [read, assign] Zoom level. Zoom uses an exponentional scale, where zoom 0 represents the entire world as a 256 x 256 square. Each successive zoom level increases magnification by a factor of 2. At zoom 10, the entire world is a 256k x 256k square, and so on.
For the controls you need to use your custom controls -,+ and for zoom in and out.
Use any of the Static Public Member Functions for adjusting the zoom levels on the GMSCameraPosition.
Then [mapView_ setCamera:myCamera];
zoom level of the camera, read this
Hope that helps!!
回答2:
float actualZoom;
#define SENSITY_OF_ZOOM 0.5
set your actualZoom after you alloc init your map:
actualZoom = _mapView.camera.zoom;
the method:
- (void) mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position{
if (fabsf(_mapView.camera.zoom - actualZoom) > SENSITY_OF_ZOOM) {
NSLog(@"user zoomed enough");
if (_mapView.camera.zoom > actualZoom) {
actualZoom = actualZoom + SENSITY_OF_ZOOM;
}
else{
actualZoom = actualZoom - SENSITY_OF_ZOOM;
}
}
}