The Google Geocoding API returns an invalid address, but Google maps show the correct location

I use the Google geocoding API to return location coordinates using the URL: http://maps.googleapis.com/maps/api/geocode/json?address=Saints%20Peter%20&%20Paul%20Parish%204070%20Central%20Parkway%20East ,% 20Mississauga,% 20L4Z% 201T6, + CA & sensor = false

Location Address:

Saints Peter and Paul Parish, 4070, East Central Park, Mississauga, L4Z 1T6.

When searching on Google maps, it returns the correct position, but when using the above URL to get the coordinates in JSON format, it returns some coordinates in Miami, USA, while my address is in Mississauga, Canada.

This is the actual location when searching for the same adders on Google Maps: https://www.google.co.in/maps/preview#!q=Saints+Peter+%24+Paul+Parish%2C+204070%2C+Central + Parkway + East% 2C + Mississauga% 2C + L4Z + 1T6 & data =! 4m10! 1m9! 4m8! 1m3! 1d126887! 2d76.3082933! 3d9.9822827! 3m2! 1i1600! 2i775! 4f13.1

but the returned coordinates are 25.7598220, -80.2133820 , which is located in Maimi

+6
source share
1 answer

The returned result is http://maps.googleapis.com/maps/api/geocode/json?address=Saints%20Peter%20&sensor=false

you also need to encode the ampersand (with% 26), otherwise everything that follows the ampersand will be accepted as a new parameter, and not as part of the address

correct result: http://maps.googleapis.com/maps/api/geocode/json?address=Saints%20Peter%20%26%20Paul%20Parish%204070%20Central%20Parkway%20East,%20Mississauga,%20L4Z%201T6 ,% 20CA & sensor = false

+3
source

Source: https://habr.com/ru/post/950227/


All Articles