Is there a Scale Controls in google map SDK for iOS ?

橙三吉。 提交于 2019-12-10 23:08:09

问题


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


来源:https://stackoverflow.com/questions/20762182/is-there-a-scale-controls-in-google-map-sdk-for-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!