niblettes
niblettes

Reputation: 175

How to present a map inside one my app's views?

One of my app's functions is to pinpoint the user's current location. It automatically requests current location and gets an address. However this is frequently not accurate enough.

I would prefer the app to still automatically request location and address, but when the user taps a button to proceed, present a map with an indication of estimated current location in the screen center, and allow the user to drag the map around to refine a more precise location.

I'm able to programmatically hand the user off to the Map app with a current location indicator, but I can't figure out how to keep the user in my app and present a map UX optimized only for refining current location (no other features beyond zoom and drag).

I have used some apps that do this, but I cannot find any guidance on how to accomplish it myself. Can anyone point the way?

Upvotes: 1

Views: 82

Answers (1)

My suggestion is to user the MapKit, position the user on it and set the span in a way that zoom is very close (like 0.0001):

let span = MKCoordinateSpanMake(0.0001, 0.0001)

let region : MKCoordinateRegion = MKCoordinateRegionMake(userLocation.coordinate, span)
map.setRegion(region, animated: true)

Upvotes: 1

Related Questions