views:

778

answers:

1

In an iPhone application I'm developing I need to get GPS coordinates to perform some actions based on the values received. Users should have two possibilities of giving the location:

  • automatically from iPhone build-in GPS
  • by finding a specific point on a map (Google Maps)

I know how to user CLLocationManager to get current position coordinates and I know how to add Google Maps using JS API. What I would like to know if how can I get coordinates for a specific point on a map that user clicks. Is that possible with UIWebView or is there any other way of getting the values I need?

+3  A: 

I'd suggest using MapKit framework (introduced in SDK 3.0) that uses google maps services. MKMapView and other classes will provide all functionality you want without the need to mess with java-script:

  1. Displaying google maps
  2. Showing and tracking user location
  3. Easy converting between view coordinates and geo coordinates (see convertPoint:toCoordinateFromView: and convertCoordinate:toPointToView: functions)
  4. Creating and showing custom map markers
  5. Reverse geocoding
  6. etc. :)
Vladimir
Can I get coordinates from the map using this framework as well or only set focus on a map based on a coordinates?
RaYell
Yes, if you set the mapview to track user location then you can obtain it later using userLocation property. If you want to use current coordinates without showing mkmapview you will have to use CLLocationManager anyway though.
Vladimir