Integrate Google Maps API into an iPhone app

后端 未结 10 2239
南笙
南笙 2020-12-23 10:51

Update: iPhone SDk 3.0 now addresses the question here, however the NDA prevents any in depth discussion. Log in to the iPhone Dev Center if you need more info.

Ok

相关标签:
10条回答
  • 2020-12-23 11:16

    For your information: The reverse geocoding API from Google for requests by XML isn't public, so it's illegal to use. The only legal way is going through their JavaScript-API, which as you found out is harder to do in Cocoa than to simply send an HTTP request.

    Alternatives: Reverse geocoding with simple XML/JSON requests is also available from Geonames or Yahoo.

    0 讨论(0)
  • 2020-12-23 11:18

    UPDATE - iPhone 0.3 includes MapKit, which will hopefully be significantly faster than using the JS API. The blurb says that it will include reverse geocoding.

    You can't make a request directly in objective-C, at least not within the terms of the Google API. The Google API is written in Javascript. You could use an objective-c to JS bridge, as the Google Maps Component does, but that doesn't really solve the issue - you're still making JS calls!

    Unfortunately, that means you a) need to use a webview b) need to use the JS API which is slow... compare with the Google Maps application which uses a completely different OTA protocol (try packet sniffing it).

    The Google Maps Component is, however, a useful tutorial in how to make simple calls to the API.

    0 讨论(0)
  • 2020-12-23 11:20

    Also try to take a look at google maps component.

    0 讨论(0)
  • 2020-12-23 11:22

    http://blog.cloudmade.com/2009/06/12/how-to-get-forward-geocoding-in-iphone-mapkit/

    CloudMade seems to be an open-source map/location provider - the above blog post lists details on how to get forward geocoding.

    0 讨论(0)
  • 2020-12-23 11:23

    I have created SVGeocoder, a simple forward and reverse geocoder class for iOS. It uses the Google Geocoding API, returns SVPlacemark objects (an MKPlacemark subclass with a coordinate property) and uses blocks.

    This is how you geocode an address string:

    [SVGeocoder geocode:addressString
             completion:^(NSArray *placemarks, NSError *error) {
                 // do something with placemarks, handle errors
             }];
    

    You can also reverse geocode a coordinate like this:

    [SVGeocoder reverseGeocode:CLLocationCoordinate2DMake(45.53264, -73.60518)
                    completion:^(NSArray *placemarks, NSError *error) {
                        // do something with placemarks, handle errors
                    }];
    
    0 讨论(0)
  • 2020-12-23 11:24

    Now that apple have release the MapKit API for OS 3.0, I think your question has been answered. Having looked at the API docs, I can see a heck of a lot of potential! I still would like to see reverse geocoding webservice from Google, but Yahoo will do in the meantime.

    0 讨论(0)
提交回复
热议问题