about positioning myself,some problems

前端 未结 2 1974
生来不讨喜
生来不讨喜 2020-12-11 12:24

I am a new to google map sdk for ios.I have added a map on a view.When I enter this mapView,I want to positioning myself.So I wrote :

GMSCameraPosition *came         


        
2条回答
  •  半阙折子戏
    2020-12-11 12:54

    NOTE: This answer is wrong, see Robert's answer.

    The Google Maps SDK for iOS doesn't have any delegate to let you know when the device's position has changed.

    You would need to use the CLLocationManager class yourself, to get the device's current position, and then update the map view.

    UPDATE:

    To update the map view from the new CLLocation provided by the location manager, you do something like this:

    GMSMapView* mapView = ...;
    CLLocation* location = ...;
    GMSCameraPosition* camera = [GMSCameraPosition 
        cameraWithLatitude: location.coordinate.latitude
        longitude: location.coordinate.longitude
        zoom: 6];
    mapView.camera = camera;
    

    Or if you want the map view to animate to the new location, then use this:

    [mapView animationToCameraPosition: camera];
    

提交回复
热议问题