使用 iPhone iOS Xcode 4 的地图视图或谷歌地图显示当前位置到目的地
所以我是一个全新的人,不知道从哪里开始。我基本上想创建一个视图,显示用户当前位置并将他们引导到我设置的位置(公园、音乐会、商业等)。这看起来相当简单,但网上有太多的雾里看花,我不知道从哪里开始或如何结束。调用google地图或者使用SDK中的mapview会更容易吗?
更大的问题是你如何做到这一点?我的意思是我可以创建简单的视图并加载网络视图,但我无法弄清楚这一点。
SO I am a totally new and do not know where to begin. I basically want to create a view that shows the users current location and directs them to my set location (park, concert, business, etc.). It seems fairly simple but there is so much smoke and mirrors online that I do not know where to start or how to finish. Would it be easier to call to google maps or use the mapview in the SDK?
And the bigger question is how do you do this? I mean I can create simple views and load webviews but I can not figure this out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
使用 MKMapView ..其设置相当简单——您可以从 CLLocationManager 获取当前位置并将其坐标传递给地图视图。
http://mithin.in/2009/06 /22/using-iphone-sdk-mapkit-framework-a-tutorial
Use MKMapView .. its fairly straightforward to set up -- you can get the current location from CLLocationManager and pass its coordinates to the map view.
http://mithin.in/2009/06/22/using-iphone-sdk-mapkit-framework-a-tutorial
看看这个网站 http://www.martip .net/blog/localized-current-location-string-for-iphone-apps
它将帮助您处理当前位置的问题。
Have a look at this website http://www.martip.net/blog/localized-current-location-string-for-iphone-apps
it will help you with the current location thing.
路线是地图应用程序的一部分,在 MapKit API 中不可用。要为用户提供 Google 地图方向,您需要使用地图 URL 方案,如 Apple URL 方案参考。具体来说,您需要在 URL 中包含
saddr
和daddr
参数,它们分别指定路线搜索的起始地址和目标地址。我相信您可以为这些参数传递纬度/经度坐标对(以逗号分隔),但您必须进行一些实验才能找到正确的格式和顺序。Directions are part of the Maps application and are not available in the MapKit API. To give your users Google Maps directions, you need to use the Maps URL scheme, as documented in the Apple URL Scheme Reference. Specifically, you need to include the
saddr
anddaddr
parameters in the URL, which specify the start and destination addresses for a directions search, respectively. I believe you can pass latitude/longitude coordinate pairs (comma-separated) for those parameters, but you’ll have to experiment a bit to find the correct formatting and order.你所说的“直接”是指实际显示一条如何到达那里的路径吗?没有API。你可以在地图上的任何地方放置一个图钉,向人们展示某物所在的位置,但他们必须自己弄清楚如何到达那里。
您正在寻找的向地图添加点的术语是向 MKMapView 添加注释。
By "direct" do you mean actually show a path for how to get there? That there is no API for. You can place a pin anywhere on a map to show people where something is, but they have to figure out how to get there themselves.
The term you are looking for to add points to a map is adding Annotations to an MKMapView.
看看这个网站,它可能会帮助您 http://www .raywenderlich.com/2847/introduction-to-mapkit-on-ios-tutorial
Have a look at this website it may help you http://www.raywenderlich.com/2847/introduction-to-mapkit-on-ios-tutorial