抓住苹果地图的道路 [英] snap to road for apple maps

查看:184
本文介绍了抓住苹果地图的道路的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目不得不使用苹果地图,corelocation和apple的mapkit - 第三方接口是不允许的。



我需要显示一个地图视图显示用户当前位置(标准蓝点),并同时将一个针脚放置在最靠近用户当前位置的道路上 - 一个快速到路,这是用户最近位置的最佳估计。



我知道如何检索用户的当前地址并使用返回的街道名称和地址,但是我不知道如何在mkmapview中将引脚添加到生成的街道。我查看了mkdirections请求,但不确定如何调整返回的数据来解决这个问题。



提前感谢您的帮助!

解决方案

我想通过调整位置服务模式,您可以通过位置服务获取路线。



Apple的 CLLocationManager上的开发人员文档提供四个活动模式:




  • 其他〜未指定

  • 汽车〜在汽车,卡车,公路车辆

  • 健身〜行人相关活动

  • 其他导航〜火车,飞机,船



(没有评论第一和第四之间的模糊。在开发者文档中还有一些比我的几个字更多的细节



基本上您将 CLActivityType 设置为 CLActivityTypeAutomotiveNavigation ,假设你是一辆公路车辆,它会做出明智的事情。从我所看到的,这更积极地捕捉到车辆道路,尽管你仍然受到苹果地图的保真度的限制。


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!

解决方案

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.

这篇关于抓住苹果地图的道路的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆