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.
Related
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.
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.
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.
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.
I am using reverse geocoding in Google Maps to get an address from a LatLng position.
However, the formatted address (formatted_address) returned in the result is shorter than the address that I get from using an autocomplete for the same point.
How can I get the same (longer) description using reverse geocoding?
I have a similar problem/request posted at: Google Maps Address Components Geocoding vs Places API - Short vs Long Name
For now, if you take the resulting formatted_address from the geocoder and pass it into a query for the new Places API, get the details for the resulting place.reference, and lastly grab the formatted_address from that response, you'll get a long form address.
Not very clean (hence my feature request at gmaps-api issue list), but it should work for now.
Alex