how to get the complete address(es) using a business name? - google-maps

I know that google maps's JSON return includes a "formatted_address" that gives you the full readable address but I've tested it on a couple of places with no success, the lat and lng coordinates aren't correct either. If I manually search it using maps.google.com it would be correct so I know the input is specific enough. How can I use the API to do this? What if the input is vague? Can I get a JSON return that includes all possible locations? (i.e. McDonalds in NYC will surely return many coordinates)
example:
http://maps.googleapis.com/maps/api/geocode/json?address=time+square+nyc&sensor=false
this returns the CORRECT coodrinates and full address that I can use.
http://maps.googleapis.com/maps/api/geocode/json?address=amc+loews+boston&sensor=false
this does not. but of course if i just search "amc lowes boston" manually it returns the correct address on google maps.

I think you're looking for Google Maps' Places Library.

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 Maps - Show address instead geocodes

I have link with geo-coordinates (below), when I reach by this URL to the google maps page, in Input I see my geo-coordinates.
Is it possible to get their Human-readable Address instead of geocodes, without changing URL format (should be used geo-coordinates) ?
https://www.google.com/maps?&z=16&q=51.5362671,-0.11687110000002576&ll=51.5362671,-0.11687110000002576
If I understood question correctly, you need to use Reverse Geocoding. I found some links. It aren't solutions of your problem but (I hope) these examples help you to find solution.
Reverse Geocoding. This page has input where you can put coordinates and check the address. I put coordinates 51.5362671,-0.11687110000002576 and get result: Carnegie Street (Stop L), London N1, Великобританія. From code you can find how to get formatted address.
Geocoding Service. Read about Geocoding Responses: formatted_address field and Reverse Geocoding (Address Lookup). This doc also has examples how to get formatted address.
Perhaps, this link also can help you:
Reverse Geocoding: Get address from Latitude and Longitude using Google Maps Geocoding API
If you get formatted address you can use jQuery .val() method to set value for input:
var address = ... // code to get formatted address
$("selector_for_input").val(address);
Here you can find example of using .val() method.
I know that these links aren't 100% solutions of your problem but I hope you can find there answer for your question.

Link to street view URL using address?

Is it possible to link directly to street view from an URL using only the address (and not lat/lng)?
For example, is there a way to do something like
http://maps.google.com/maps?q=&layer=c&address=Street,number,state&cbp=11,0,0,0,0
Instead of
http://maps.google.com/maps?q=&layer=c&cbll=31.335198,-89.287204&cbp=11,0,0,0,0
?
Lat/lng from geocoding tends to not be recognized by street view as being too far from a street, sometimes getting the wrong street altogether, because the lat/lng it generates may be off the street, as it tries to match the location of a house.
I have looked everywhere and even tried playing with google's URLs on my own, but I can't find anything on it. Most sources won't even mention address. I'm currently using the url sample from this question, but it still isn't really what I'm looking for.
If this is really not possible, could someone link to a source/documentation where it says so?
Edit: Thank you everyone for the answers, but none really address the issue with street view and addresses. I'll look into forwarding this to google. I'll post here if I get a reply.
Let's enhance your code, if you paste the code in browser then you will be redirect to google maps and will show result what you requested.
http://maps.google.com/maps?&q=Space+Needle,Seattle+WA
If you would like to pass the value (address) via php or any other code type then simply it will not work, you cannot use google maps without API to enhance your requirement. Lat & Lng is basic practice to show map and not require any api, but if you would like to pass additional properties then you will have to use google maps api to do so. Detailed documentation can be found here
https://developers.google.com/maps/documentation/embed/guide
but let's try an example try this code in browser
https://www.google.com/maps/embed/v1/place?q=Mumbai,+Maharashtra,+India
You will get an error that api key not found but if you try this one
https://www.google.com/maps/embed/v1/place?key=AIzaSyD4iE2xVSpkLLOXoyqT-RuPwURN3ddScAI&q=Space+Needle,Seattle+WA
Then you will get output. Hope it helps!
First reverse geocode to find the lat lng using another Google Service API.
Then feed the resulting lat lng into the streetview endpoint parameter.

Google Geocode api returning incorrect result for a particular address

When I try to geocode one of the adress using Google geocode api, Google api returns an incorrect location.
search address : republic of estonia
result from google api: spain
I am using javascript Google api to geocode the address. For some other location the result is correct but for above address its incorrect.
If we enter below url in browser, we get the JSON back and it is showing result somewhere in Spain rather than showing result in Estonia.
http://maps.googleapis.com/maps/api/geocode/json?address=republic%20of%20estonia
I tried same addres in maps.google.com and it takes me to correct location.
Have a look at the Estonia country feature in Map Maker:
https://www.google.com/mapmaker?iwloc=0_0&fmi=0_0&gw=39&fid=5085290329182063613:4677726785527621059&dtab=overview&ll=58.620408,24.93212&spn=3.101226,8.668213&z=7&lyt=large_map_v3&htll=58.560236,25.449737&hyaw=278.7642140009582
If you check the list of names for this feature, you will see that there is no 'Republic of Estonia' in the list. The name is simply 'Estonia'.
The request for 'Estonia' works as expected:
https://maps.googleapis.com/maps/api/geocode/json?address=estonia&key=YOUR_API_KEY
If you believe that 'Republic of Estonia' must be in the list of the names please Send a feedback (bottom right corner) to Google from this page
https://www.google.com/maps/place/Estonia/#58.7223142,23.1414399,7z/data=!4m5!3m4!1s0x4692949c82a04bfd:0x40ea9fba4fb425c3!8m2!3d58.595272!4d25.013607?hl=en
Google assumed you were looking for "Calle Estonia" or "Estonia Street".
You should request that Google add "Republic of Estonia" to their list of spaces. Google, and most other mapping services, only have "Estonia" or "EST" in their list of places.
Also, you may want to use a different API if you need to get an accurate answer. Google is really good, but Google tries to "guess" what you mean and always gives you a result. But, a service like SmartyStreets matches searches to databases of addresses (so if the search is not a "real" place, it will tell you).
(Full disclosure: I have worked for SmartyStreets.)

Google Maps API: Searching

I'm working on a shipping system for my company where user's enter (along with a bunch of other information) the destination that something needs to get shipped to. The system that we are migrating from just used this information as static text, so people would enter shorthand addresses such as "Alsip 60801".
My original thought was that that sort of shorthand text would work perfectly with Google Maps API, because I can type shorthand things into maps.google.com, and it generally works.
So, I wrote up some code to run geocoding on their shorthand inputs. To my unfortunate surprise, the results returned from the geocode search were greatly different from those that are returned from maps.google.com.
For example, when I search for "Alsip 60801" on maps.google.com, I get Alsip, IL 60801. That's correct. But when I search using the Google Maps API, I get some Alsip up in Canada.
Is there another search function that I should be using for the Google Maps API? Or some sort of flag that I am missing?
For reference, this is the short version of my code:
var geocode = new google.maps.Geocoder();
geocode.geocode( {'address': 'Alsip 60801' }, function(results, status) {
console.log(results[0].geometry.location);
//Outputs the LatLng of a Canada address
});
Edit 1: I forgot to mention, I did try setting the region on the geocode request. I set it to us, and got the same results.
Update - Answered: I marked #Jitimaro's answer as correct, because tacking the country code onto the end of the results does seem to work. I'm not sure if that will work with every sort of input (it's hard to predict shorthand address formats), but it seems to work fine for now.
However, I actually am handling this a different way. Instead of just tacking a country code onto the end of the address, I'm actually providing a LatLngBounds parameter on the end of my geocode request. That gives all addresses within my bounds preferential treatment as it is searching.
When you search with the website you should get a preview like this: http://maps.google.com/maps?q=Alsip+60801. When you search a reverse geocode you must parse the result to match your country http://maps.googleapis.com/maps/geo?q=Alsip+60801. You can check the different url with a network sniffer. Or you can add the country to your url http://maps.googleapis.com/maps/geo?q=Alsip+60801+USA.