问题
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...
回答1:
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.
来源:https://stackoverflow.com/questions/5813963/generate-kml-file-within-iphone-app