Why do I get different result from geocode api vs google maps - json

I am new to google geocode API but I am planning to use the free version to get map coordinates for nearby golf courses. I started with my home course:
http://maps.google.com/maps/api/geocode/json?address=Karlstad+golfklubb
Plus "&key=[my generated api key]"
I get a result with status="OK" but the resulting long/lat is not correct. It's near but misses with 7-8km.
When I use maps.google I get correct location. Searched for "Karlstad golfklubb".
https://www.google.se/maps/place/Karlstad+Golfklubb/#59.4346545,13.5140563,17z/data=!3m1!4b1!4m2!3m1!1s0x465cb41aca8c1467:0x64836d18f18df2f6
Why do I get different geo locations when using the same keywords. Do they operate on different databases or do I need to enter more params?
I also tried with other nearby courses like "sommarro" and "bryngfjorden" but for they I get zero result. But no problem finding them in google maps.

If you look at the JSON code, they describe the formatted_address as
"formatted_address" : "Karlstad Golfbanan Jako, 652 30 Karlstad, Sweden"
Which if you enter into Google Maps shows the correct longitude and latitude in the JSON.
https://www.google.com/maps/place/Karlstad+Golfbanan+Jako,+Sweden/#59.3602394,13.472185,17z/data=!3m1!4b1!4m2!3m1!1s0x465cb23bc0f46911:0x66ceae446bdc95dc

Related

How to find municipality and postal code that are in range from coordinates?

Is there a way by using azure-maps or google-maps to get from longitude and latitude all postal codes and municipalityes that are in range of X kilometers?
I've yet checked the Get Search Nearby of azure, but it returns only points of interests and it is not possible to specify in the API a range in which the data should be get.
In Azure Maps, getting all postal code/municipalities within a specified distance of a location or within an area is not currently available. However, this is something being investigated as a possible future service. Consider submitting this as a feature request here: https://feedback.azure.com/forums/909172-azure-maps
I don't believe Google Maps has any such service either.

Google Places API: retrieve restaurant in Rome

It's hard for me to understand why Postman is returning me restaurant in US even if I'm restricting the research to postal_code:00100|country:IT (00100 = Rome zip code, IT = Italy)
This is my GET:
https://maps.googleapis.com/maps/api/place/textsearch/json?query=restaurant&components=postal_code:00100|country:IT&key=MYSECRETKEY
Where am I wrong?
The components filtering is not supported in Places API text search.
Take a look at official documentation, there is no components parameter available:
https://developers.google.com/places/web-service/search#TextSearchRequests
To bias your results you should use the location and radius parameters.
The components filtering is supported only in Geocoding API. So you can solve the issue in two steps.
Get position of the postal code using Geocoding API
Search restaurants using Places API text search and location from the first step
E.g.
Get location of postal code 00100
https://maps.googleapis.com/maps/api/geocode/json?components=postal_code%3A00100%7Ccountry%3AIT&key=YOUR_API_KEY
Now use coordinate 41.9228369,12.5014301 to search restaurants in 5km radius
https://maps.googleapis.com/maps/api/place/textsearch/json?query=restaurant&location=41.9228369%2C12.5014301&radius=5000&key=YOUR_API_KEY
Hope this 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)

Google maps APIs to return place' type based on latitude & longitude

I am trying to build an application in which I need to retrieve location's type based on latitude and longitude. I tried using google's places API but not getting satisfied results.
For eg, if I want to know if the user searches for SFSU, it should be stored as 'university'. I can get its latitude/longitude from geocoding APIs.
https://maps.googleapis.com/maps/api/geocode/json?address=SFSU&key=YOUR_KEY
But from places API, I cannot get the exact type, I mostly get it as street or establishment:
https://maps.googleapis.com/maps/api/geocode/json?latlng=37.7244047,-122.4760196&key=YOUR_KEY
Similarly, I wanted to get cafe for any starbucks or mall/shopping-center for any mall.
Edit:
I got confused between geocode API and places API as geocode API also returns place' type.
I found that places API returns multiple results even if we provide correct latitude and longitude. So if we need the perfect result, we need to provide sort filter with Places API.
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=(lat),(long)&rankby=distance&key=YOUR_API_KEY
It looks like you are using reverse geocoding, not the Places API.
Request to Places API should be something like:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=37.7244047%2C-122.4760196&radius=10&type=university&key=YOUR_API_KEY
This one returns 'San Francisco State University, 1600 Holloway Avenue, San Francisco'
https://developers.google.com/places/web-service/search#PlaceSearchRequests
Hope it helps!

Google maps GeoCode API doesn't return any result at all?

This is weird. When I search something like "The New York Palace Hotel,America,New York" in Google maps app's search box I get exactly the hotel on the map.
However When I use the maps API,
A GET at http://maps.googleapis.com/maps/api/geocode/json?address=The%20New%20York%20Palace%20Hotel,America,New%20York&sensor=true
I get ZERO results in the response.
It doesn't even give New York as the option in search results.
I am making an app where I use this API to get the lat-long for user provided address.
Now, I don't know why this Google maps API doesn't work the way the Google maps app works.
BUT I wanted to know, is there a way to search and provide Google maps API these search terms as meaningful words where instead of taking whole string as one parameter it knows which city I am searching and which Address I ams searching.
If not, then only option left with me will be to Once the first results fails I make another query for city name only.
recently, i was given a similar task, and came to know the api works reverse... i.e.. we can get address for lat lon that we provide.. and that too has its own restrictions (i.e.. no.of addresses resolved per request, mostly some 2500 address per day something...)....here you can get some info over that...
You are using the Geocoding API. "The New York Palace Hotel,America,New York" is not an address, it is a "place". The Places API might be a better option.
Example of your query using the (javascript version of) the Places API