0

In my iOS app I want to let user to pick an address with a long press gesture on a GMSMapView. So I implemented the mapView:_ didLongPressAtCoordinate:_ method to take the coordinate he choose and to make reverseGeocoding and get the address:

    let geocoder = GMSGeocoder()

    geocoder.reverseGeocodeCoordinate(coordinate) { response, error in
        if let address = response?.firstResult() {
            // Everything ok
        } else {
            // Here the response is 'nil'
        }
    }

What can I can do here, when the response is nil to get the nearest location coordinate with a human readable address?

  • Kindly provide log for errors – Mr.Rebot Apr 03 '16 at 20:01
  • There's no error. error var is nil. Simply, response is nil too. – Francesco Frascà Apr 03 '16 at 20:03
  • Have you checked the logs if you are getting coordinates when doing the `mapView: _ didLongPressAtCoordinate:_`? – Mr.Rebot Apr 03 '16 at 20:06
  • If not, here I found an existing SO question for [how to get the touch location on map] (http://stackoverflow.com/questions/25685918/how-to-get-the-latitude-longitude-of-a-touch-location-on-mapview-using-google?lq=1). I hope this helps – Mr.Rebot Apr 03 '16 at 20:09
  • Yes. The location coordinate is valid. The problem is when the user made a long tap on the sea, as example. There's no valid address in there and I want to get the nearest address. – Francesco Frascà Apr 04 '16 at 07:40

0 Answers0