MKMapView's user location is wrong on startup or resume

前端 未结 7 2164
臣服心动
臣服心动 2021-01-17 19:15

When I start my application fresh, or resume after a long time, MKMapView\'s notion of the userLocation is wrong and shows me in the middle of the sea.

I am using th

7条回答
  •  遇见更好的自我
    2021-01-17 19:55

    In my apps I used these methods:

    First - it's good to have a default position (for example - application is about a city - then zoom in to show whole city) (on first - first app opening, when no data downloaded)

    Second - if user has already used map - can store his coordinates, and show those (+ span(zoom) level) in case there are no other data available.

    Third - in case of data:

    1.) If database has already some coordinates - on first map opening (when application has been closed) - zoom out/in to show all pins on map.

    2.) When still in map and just arrived updates (new locations or changed something), there are two possibilities :

    2.1.) If user has not zoomed in to any location - map zooms in/out to show all locations.

    2.2.) if user has zoomed in - locations are updated, but map doesnt zoom out

    Ofcourse - then there are also some filter buttons (for example : search, user location, and some more - which filters locations, and zooms out/in to show filtered results)

提交回复
热议问题