I am sending the following request to the google autocomplete api in attempts to get a street address with the zip code included.
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=917&component=country:us&key=[MyApiKey]&types=address&bounds=defaultBounds&stricktBounds=true&address_components=postal_code&fields=address_components
I can't seem to figure out how to ask for the zip code in the query parameters. When I pass a full address with the zip in the input, google returns the zip code, but I would like it to always return the zip code.
I can make another request to the google maps api and pass the place id that I get from the autocomplete endpt and get the full address with the following request.
https://maps.googleapis.com/maps/api/place/details/json?fields=formatted_address&place_id=Eic1MDEgQ29sbGVnZSBBdmVudWUsIEdyZWVuc2Jvcm8sIE5DLCBVU0EiURJPCjQKMgldGdoYQBlTiBEjv0Tw4tNAARoeCxDuwe6hARoUChIJVXM4RSQZU4gRLNRdpst7vxAMEPUDKhQKEgmVWLxpQBlTiBGKDjnnY2NAzg&key=[my_Key]
But I would like to do a search and get the zip code all in one request.
Edit:
The following works in javascript with the google api javascript package, but I cannot use javascript in my project...
https://maps.googleapis.com/maps/api/place/js/AutocompletionService.GetPredictions?1s501&fields=formatted_address&key=[my_key]
Thanks for any help!!
The google api place textsearch endpoint can be used instead with field type formatted_address to return the zip code.
https://maps.googleapis.com/maps/api/place/textsearch/json?query=971&fields=formatted_address&inputtype=textquery&key=[my_key]
Related
I am using google maps API to get all the place information like phone number , opening hours .. when I test with the placeid in the developers site I get all the details but when I send send my placeid I get just the address_components details.
developers :
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4&key=AIzaSyBz2O-udgMv8PnaY-2tW118Uz1182ApEiw
My link:
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJ2xEZitrOUUYR0a9wjkKF9_g&key=AIzaSyBz2O-udgMv8PnaY-2tW118Uz1182ApEiw
The place ID ChIJ2xEZitrOUUYR0a9wjkKF9_g from second request returns result of type route. Places API can return addresses as well, not only businesses.
You can easily check it with Geocoding API request:
https://maps.googleapis.com/maps/api/geocode/json?place_id=ChIJ2xEZitrOUUYR0a9wjkKF9_g&key=YOUR_API_KEY
or open it in Geocoder tool:
https://developers-dot-devsite-v2-prod.appspot.com/maps/documentation/utils/geocoder/#place_id%3DChIJ2xEZitrOUUYR0a9wjkKF9_g
The route is not a business, so it doesn't have phone, open hours, etc.
I found the problem it was with the place_id and not the request , as xomena saying the the request returns result of type route, but I tried what 2 requests you wrote and it returns the same data I got with my request because of the placeId.
thank you all anyway :)
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.
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 use google maps static api to show maps on my website and use the following url:
http://maps.googleapis.com/maps/api/staticmap?center=usa&size=800x300&maptype=roadmap&sensor=false&markers=color:blue|label:S|usa
However, if enter a non-existing address, google will return a picture like this:
http://maps.googleapis.com/maps/api/staticmap?center=notexistingaddress&size=800x300&maptype=roadmap&sensor=false&markers=color:blue|label:S|notexistingaddress
I would like to know, how can I determine, if an address exists or not, using google maps static api. I cannot use javascript, because this code is executed on server.
After reading the docs, I think that the Google Maps Static API has nothing (exept the way I suggest like verify the return of the picture manually or only the keyword notexistingaddress) to verify if an address exists or not.
The best way to do validation is I think the Google Geocoding API, where you can outpout a Json / XML of a given address. The status code of ZERO_RESULTS which indicates that the geocode was successful but returned no results may interest you.
I am trying to use Google places autocomplete API for one of my application.
It works allright. But, I dont get the key formatted_phone_number in the result for the place detail request.
This is what I've been trying:
Step1: Call to autocomplete api with keyword "Mike's chili" as below:
https://maps.googleapis.com/maps/api/place/autocomplete/xml?input=Mike%27s%20chili&types=establishment&sensor=false&key=AIzaSyC2L1pPVbgCXUFuobrHS6vjN1RPbjibaME
Step2: Use the reference key in the first result of above request and make call to google Places Detail api as below:
https://maps.googleapis.com/maps/api/place/details/xml?reference=CmReAAAAtR79EFJeGGLjMflCzFh_n5Rl4rEJfU_dg-zs-1ZyPVHQQmMneLO2P0J4APa3dpV2YvscqbyOK50iARnevHcUOnRvAc33hDGQQAPWxJbzSTw0GF3nDOXP1R7Zep68Yc37EhAmWbhrqVT3Ht-SffUHi1jgGhR81n4FV2ywKBkmbS8_4MrsI85w8w&sensor=false&key=AIzaSyC2L1pPVbgCXUFuobrHS6vjN1RPbjibaME
But, I dont get the field called formatted_phone_number in return. This happens for some of the other results also.
When I search for the same in Google maps, I get the phone number.
Can someone please help me on this?