MKMapView Route/Directions

前端 未结 2 1246
[愿得一人]
[愿得一人] 2021-01-30 19:16

I found that the Google Maps API supports Directions through:

var map;
var directionsPanel;
var directions;

function initialize() {
  map = new GMap2(document.g         


        
2条回答
  •  走了就别回头了
    2021-01-30 19:41

    I was originally going to say (and I'm sure others will bring it up) that the Google Maps terms-of-use says you can't use directions if you plan to use MapKit. But then I double-checked http://code.google.com/apis/maps/terms/iPhone.html and couldn't really find an explicit restriction. If I understand it correctly, it actually says you can't use directions as long as it's tied to a GPS-driven realtime turn-by-turn functionality. You should use your own judgement as to whether it's OK or not and whether it affects your chance of acceptance on the AppStore.

    As far as getting the actual data in Objective-C your best best is to look at the Google Ajax search documentation [ http://code.google.com/apis/ajaxsearch/documentation/ ] especially the section under Flash and other Non-Javascript Environments. It explains a RESTful API where you can send HTTP GET requests to Google and get JSON data back. That's the only way I've found to get programmatic data out of Google that isn't tied to Javascript.

    Once you've figured out the proper URL to invoke you can wrap the whole thing in an ASIHTTPRequest call and feed the result to a JSON parser. One thing to keep in mind is that the RESTful API returns only a few results (between 4 and 8) at a time and you have to keep going back until you've got all the data. There also appears to be a 64-item cap to the number of results returned by the API so some complex edge-cases may be affected.

提交回复
热议问题