A discrepancy when locations are retrieved from Geocoding API and Google maps - google-maps

I have encountered a discrepancy between Geocoding API and Google maps when checking the same locations.
I tried the following locations in Google maps:
33 Place Massena, 06000 Nice, France (as the start location)
Gare de Nice Ville, Avenue Thiers, 06000 Nice France (as the destination)
The distance is between 1.7 and 2.2 km.
However, when I used Google maps and replaced the above destination with its Geocoding API, the distance is 3.7 km
The API I used is in the following link: https://maps.googleapis.com/maps/api/geocode/json?address=Gare%20de%20Nice%20Ville,%20Avenue%20Thiers,%2006000%20Nice%20France
Please see the attached pictures for further references.
Could you please check and let me know why it is different?

I think this is intended behavior, you should understand the difference between applying the address string and applying the coordinate.
When you apply the address string 'Gare de Nice Ville, Avenue Thiers, 06000 Nice France' the directions service will geocode it to the establishment with place ID ChIJnfu2MAbQzRIR1aBedCqfGXA.
https://google-developers.appspot.com/maps/documentation/utils/geocoder/#q%3DGare%2520de%2520Nice%2520Ville%252C%2520Avenue%2520Thiers%252C%252006000%2520Nice%2520France
In this case the directions service will use an access point defined for this establishment. Looking at your screenshots I guess that the access point for this establishment is like shown in my screenshot
If you apply the coordinate 43.704612,7.261933 the directions service will just snap it to the nearest road. Something similar to the following request
https://roads.googleapis.com/v1/snapToRoads?path=43.704612%2C7.261933&key=YOUR_API_KEY
The result of the snapping to the road is shown in the following screenshot
As you can see the snapped point and the access point for establishment are different. I suppose that there are certain turn restrictions that doesn't allow to use Avenue Thiers to reach the snapped point and you make a big detour via Voie Pierre Mathis in this case.
I hope my explanation solves your doubts!

Related

Google Directions API Travel Mode TRANSIT not working for street_address

Apologies if I'm writing obvious question.
Though I cannot find document anywhere online so I have decided to ask here.
Is it the case that transit mode in Goolge Directions API is only valid if origin and destination are point of interest?
If either or both address is type street_address, I am not able to receive response containing travel_mode=TRANSIT.
What I want to achieve from the API is a result like Google Map, where it outputs optimistic route between the origin and destination; consisting waypoint(s) of public transport in the middle of the trip.
E.g. Point of Interest to Point of Interest returns fine
https://maps.googleapis.com/maps/api/directions/json?origin=Wynyard%20station&destination=Chatswood%20station&mode=transit&transit_mode=rail&key=[key]
E.g. Point of Interest to street_address returns ZERO_RESULTS
https://maps.googleapis.com/maps/api/directions/json?origin=Wynyard%20station&destination=441%20Victoria%20Avenue&mode=transit&key=[key]
E.g. Inserting "Wynyard Station" as origin and "441 Victoria Avenue" as destination in Google Map returns route including both transit and walk to the destination.
The issue with your request is that you are using incomplete address string '441 Victoria Avenue'. This is really ambiguous query. If you check it in Geocoder tool, you will see that this string is resolved to '441 Victoria Ave, Forrest City, AR 72335, USA'
https://google-developers.appspot.com/maps/documentation/utils/geocoder/#q%3D441%2520Victoria%2520Avenue
So, you try to find a transit (train) directions between one place in Australia and another one in the USA.
ZERO_RESULTS is expected in this case. You should specify a more precise address string or use autocomplete to search transit directions using place IDs.
https://developers.google.com/maps/faq#geocoder_queryformat
https://developers.google.com/maps/documentation/geocoding/best-practices
For example, using '441 Victoria Avenue, Sydney' I can get transit directions
https://maps.googleapis.com/maps/api/directions/json?origin=Wynyard%20station&destination=441%20Victoria%20Avenue%2C%20Sydney&mode=transit&alternatives=true&transit_mode=train&key=YOUR_API_KEY
You can check this in Directions calculator tool:
https://directionsdebug.firebaseapp.com/?origin=Wynyard%20station&destination=441%20Victoria%20Avenue%2C%20Sydney&mode=transit&alternatives=true&transit_mode=train
Hope it helps!

Google Directions API Result is different from Google Maps result

I am developing an app that displays the Distance & path between 2 distances. In this case I have used following addresses:
Source: Major Bhola Ram Enclave
Destination: Ring Road Mall, Sector 3, Rohini, New Delhi, Delhi
When I use Directions API then I get following result, see image below:
But, when I search these addresses in Google Maps then I get different Result.
Click here to see Google Maps result
I searched a lot about this but I couldn't find any reason/solution for this.
Please guid me in right direction.
Thanks.
Those are not addresses, they are places. If you want a similar result to Google Maps, you need to use the placeId or the coordinates returned for that place from the places service in the directions request.
http://www.geocodezip.com/v3_example_geo2.asp?addr1=Major%20Bhola%20Ram%20Enclave&addr2=Ring%20Road%20Mall,%20Sector%203,%20Rohini,%20New%20Delhi,%20Delhi&place=1&place=2
(uses the results from the place service)

Maps.google.com and Google Maps V3 API geocoder gives different results

I have the following address "12635 SCARSDALE ST, SAN ANTONIO, Texas 78217". If I enter this address in maps.google.com, it gives me the correct address. If I use the Google Maps V3 API geocoder ( http://maps.googleapis.com/maps/api/geocode/xml ), it returns a lat/long in scarsdale dr, Austin, tx( partial match). I used http://gmaps-samples-v3.googlecode.com/svn/trunk/geocoder/v3-geocoder-tool.html as well and it gets the same results.
Usually when this happens, it is something in the address( wrong zip code, misspelling etc).
I cannot see what could be wrong here or why the inconsistency. Any Ideas would be appreciated.
Note: Mapquest on the other hand does return the correct lat/long for this address.
It looks like you found an error in Google's data. Google has identified this location as "12635 Scarsdale, San Antonio, TX 78217" (note the missing ST portion of the address).
Their API is probably relying on proximity to find the closest match to the data provided (i.e. what is the closest "12635 Scarsdale" to San Antonio, TX)
You could help them (in this instance) by clicking the Send Feedback link in the bottom right corner of the map.

google map and api shows different results

I am surprised whether i am doing any wrong or not. When i am finding the distance between two locations on google maps say maps.google.co.uk and when i query their API i get different result. Am i missing somethng?
Origin:Hyde Park Corner Station, Knightsbridge, London, United Kingdom
Destination:The Ritz London, United Kingdom
Result: 1.2 miles
And when i am using api:
http://maps.googleapis.com/maps/api/directions/json?origin=Hyde%20Park%20Corner%20Station,%20Knightsbridge,%20London,%20United%20Kingdom&destination=The%20Ritz%20London,%20United%20Kingdom&region=gb&sensor=false&alternatives=true&units=imperial
Result:4.3 miles or 5.0 miles etc.
Why is there so much of difference . Am i missing something.
There are significant differences between Google Maps and a service like directions(or geocoding)
Google Maps at first is an implementation of Google Places, and that's the issue here. The directions-service uses geocoding to resolve the addresses, while Google Maps uses the PlacesService.
When you draw the route using the directionsRenderer, you will see that there are different start-and end-locations.
But when you first request the PlacesService to get the coordinates of the places, and use these coordinates to request the directionsService, you will get a result near by the result of Google Maps(the duration may differ, because the directionsService by default will not return results depending on the current traffic)

Google geocoding inaccuracy (in Israel)

I'm trying to use Google Geocoding API, but i keep on getting a very inaccurate answer (off by 3.2 KM).
Here is an example:
http://maps.google.com/maps/api/geocode/json?sensor=true&address=Hava%27ad+Haleumi+21+Jerusalem
I get the coordinate 31.7857,35.2007.
Ff you look up "Hava'ad Haleumi 21 Jerusalem" in maps.google.com, you can see that the location is 3.2KM away from what Google Geocoding API gave me.
Does anyone know why this happens?
Thank you.
Actually, the Google Maps API does not support geocoding in Israel beyond city level, so your solution is to do what you did and finding an alternate geocoding service.
The reason you got the correct location when searching on maps.google.com is because the API uses a different provider than maps.google.com due to licensing issues.
Here is a spreadsheet detailing the coverage area for Google Maps.
It's possible to use waze.co.il instead of google:
Their JSON API is
http://www.waze.co.il/WAS/mozi?q=yourAddress&token=yourToken
(Also, as stated in this thread http://www.waze.co.il/forum/viewtopic.php?f=21&t=6113
reverse geocoding is a paid service.)
Take a look at the response. You are getting a partial match and the location type is approximate. If you look at the veiwport you will probably find that the location you are looking for falls within that viewport. *Edit - Actually it looks like it just matched to city - Jersulem in this case - which is why you are probably off by so far