0

When converting the string(place) into Coordinates. the coordinates that are in the placemark is pointing to the direction which is different from the string i provided as an argument.

let address = "16/1, Kanchan Bagh Main Road, South Tukoganj, Indore, Madhya Pradesh"

let geoCoder = CLGeocoder()
geoCoder.geocodeAddressString(address) { (placemarks, error) in
    guard
        let placemarks = placemarks,
        let location = placemarks.first?.location.coordinates
    else {
        // handle no location found
        return
    }

    // Use your location
}

Result lat:22.7438068 & long: 75.8512509 Expected Result lat: 22.7203646 & long: 75.88234569999997.

Because of this the marker on google map is point in the wrong direction.

Any help would be Appreciated. Thanks in Advance

Ayush sharma
  • 169
  • 7

1 Answers1

-1

Use as shown below

//implementation
getPositionFromAddress(strAdress:"Rajendra Kamble Road, Yashwant Nagar, Santacruz East, Mumbai, Maharashtra. India")


//Function
func getPositionFromAddress(strAdress:String){
    let address = strAdress

    let geoCoder = CLGeocoder()
    geoCoder.geocodeAddressString(address) { (placemarks, error) in
        guard let placemarks = placemarks, let location = 
placemarks.first?.location else {
                // handle no location found
                return
        }
        print(location)
    }
Yogesh Tandel
  • 1,738
  • 1
  • 19
  • 25
  • How is it different from my code that i mentioned above – Ayush sharma Aug 02 '18 at 09:34
  • Use the below address. Because of 16/1 it is not recognising the address. let address = "Kanchan Bagh Main Road, South Tukoganj, Indore, Madhya Pradesh" I got these coordinates which are for Madhya Pradesh - +22.71068126,+75.86095231 – Yogesh Tandel Aug 02 '18 at 12:15