在 iPhone 上生成 KML 文件
在我的应用程序中,我必须借助 MKAnnotation
和 MKOverlay
类在 MKMapView
中绘制用户位置和目标位置之间的路线。我已经浏览了 Apple 的 KMLViewer
示例代码,他们提到在编程步骤之外创建 KML 文件,但我需要在 iPhone 应用程序编程内生成 KML 文件。
是否可以?我需要帮助来完成此操作。
手动获取 KML 文件的步骤
获取 KML 的过程如下:
- 转到:“http://maps.google.com/”
- 点击“获取”路线”链接
- 输入起始地址和目的地地址 (例如) 起点 = 451 University Avenue, Palo Alto, CA 94301 目的地 = #1 Infinite Loop, Cupertino, CA 95014
- 根据您的意愿修改路线。
- 单击“链接”到此页面链接。
- 复制电子邮件/即时消息链接。
- 将链接粘贴回 Safari 的地址栏。
- 将
&output=kml
添加到 URL 末尾,然后按 Enter 键。 - KML 文件将下载到您的下载文件夹中。
但我需要以编程方式完成此操作......
In my app I have to draw route between user location and destination location in MKMapView
with help of MKAnnotation
and MKOverlay
classes. I had gone through the KMLViewer
sample code from Apple in there they mentioned to create KML file outside the programming steps, but I need KML file generation inside iPhone app programming.
Is it possible? And I need help on doing that..
Steps to get KML file manually
The process to obtain a KML is as follows:
- Go to: "http://maps.google.com/"
- Click "Get Directions" link
- Type in the start and destination addresses
(for example)
Start = 451 University Avenue, Palo Alto, CA 94301
Destination = #1 Infinite Loop, Cupertino, CA 95014 - Modify the route as you wish.
- Click the "Link" to this page link.
- Copy the email/IM link.
- Paste the link back into your Safari's address bar.
- Add
&output=kml
to the end of the URL and press the enter key. - The KML file will be downloaded to your Downloads folder.
but I need this to be done programmatically...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
KML 只是 XML,在 Cocoa 中有多种生成 XML 文件的方法,例如使用 KissXML。
KML 格式记录如下:http://code.google.com/apis/ kml/documentation/kmlreference.html。
KML is just XML and there are various methods for generating XML files in Cocoa, e.g. using KissXML.
The KML format is documented here: http://code.google.com/apis/kml/documentation/kmlreference.html.