snap to road for apple maps

我的梦境 提交于 2019-12-11 06:09:23

问题


I have a project which is constrained to working with apple maps, corelocation and apple's mapkit -- 3rd party interfaces aren't allowed.

I need to display a map view showing the user's current location (standard blue dot) and simultaneously place a pin on the road nearest the user's current location -- a 'snap to road' which is a best estimate of the user's nearest location.

I know how to retrieve the user's current address and use the returned street name and address, but i don't know how to add the pin to the resulting street in mkmapview. I've looked at the mkdirectionsrequest but am unsure how to adapt the returned data to solve this problem.

thanks in advance for your help!


回答1:


I think you can get the road-snapping done by Location Services, by adjusting the location service mode.

Apple's Developer docs on CLLocationManager offer four 'Activity' modes:

  • Other ~ unspecified
  • Automotive ~ in a car, truck, road vehicle
  • Fitness ~ pedestrian related activity
  • OtherNavigation ~ trains, planes, boats

(no comment about the ambiguity between the first and fourth... there's a bit more detail in the developer docs too than my few-word summaries above)

Basically you set CLActivityType to CLActivityTypeAutomotiveNavigation, and it will do sensible things on the assumption you're in a road vehicle. From what I've seen, this more aggressively snaps to vehicular roads, though you're still limited by the fidelity of Apple's maps.




回答2:


For a snap to road feature you need the sequence of latitude and longitude coordinates of that street. You usually never get that vector info, because the owner of that vector data (TomTom and Nokia) do not allow that.

Only OpenStreetMap based data is free, and vector data is available.

ios uses TomTom data, and as expecdted you will not get the coordinates of the polyline of a street.



来源:https://stackoverflow.com/questions/19815248/snap-to-road-for-apple-maps

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