Select a position using draggable map and fixed ma

2019-09-06 04:58发布

问题:

I'm newbie to iOS development and now trying to build a very simple navigation app using Google Maps SDK. So I created a map and centered it to current position of user.

Now I need to implement the following functionality:

  • make a fixed marker that always remains in the center in a screen;
  • let the user move the map, so the fixed marker will be pointed to desired position.
  • to write coordinates of this position in some variable when user taps on marker.

Can someone please advice with some ideas how to achieve this, or with some sample code?

回答1:

For the fixed marker, you can add a small UIButton on top of your map. After the user pans the map and taps your button, you can get the location centered in map

CLLocationCoordinate2D location = mapView.camera.target;