Cross Street Coordinates - google-maps

I want the latitude and longitude of two street that cross from the Google Geocoding API.
It should be a simple matter to determine the syntax, but I am unable to find any examples.
I can, however, offer and example that doesn't work:
http://maps.google.com/maps/api/geocode/json?address=maple+street+and+main+street,+Anywhere,+MO&sensor=false
The "and" keyword is wrong. Is there a proper syntax, or should I just kill myself?

I think you've got the right syntax. Your example doesn't work because there is no Anywhere, MO so the service is returning the only thing it recognized, which was the state of MO.
The API correctly returns locations of type intersection for the queries like:
http://maps.google.com/maps/api/geocode/json?address=Main%20Street%20and%201st%20Street,%20Springfield,%20MO&sensor=false
and
http://maps.google.com/maps/api/geocode/json?address=Amphitheatre%20Parkway+and+Charleston%20Road,+Mountain%20View,%20CA&sensor=false

Related

Google Maps API query with only ZIP code provides incorrect results

We use the Google Maps API, and when a user inputs a 5 digit ZIP code, the results are correct the vast majority of the time; it treats the input as a ZIP code and returns results based on that location.
The problem that has come to our attention is that queries for certain ZIP codes (42025 is our prime example) does NOT return the expected results (Benton, KY). The API call actually returns "status":"ZERO_RESULTS". A similar search on maps.google.com will sometimes produce a positive result, but only if Benton, KY consumes a large portion of the viewport already. A workaround is to add the term "zip" in the query string.
My investigation has shown that the failed results appear to be using the 5 digit string as if a street address, which find nothing. A query for "42020" ends up showing some address near Washington D.C., for example.
Has anyone faced this issue? Any suggestions for how to address this?
I would suggest using a component filtering in your Geocoder requests in order to obtain postal codes.
Your requests will be rewritten as
https://maps.googleapis.com/maps/api/geocode/json?components=postal_code%3A42025%7Ccountry%3AUS&key=YOUR_API_KEY
https://maps.googleapis.com/maps/api/geocode/json?components=postal_code%3A42020%7Ccountry%3AUS&key=YOUR_API_KEY
Both requests return expected results to me. You can also see it in the Geocoder tool:
https://developers-dot-devsite-v2-prod.appspot.com/maps/documentation/utils/geocoder/#q%3D%26options%3Dtrue%26in_country%3DUS%26in_postal_code%3D42025
https://developers-dot-devsite-v2-prod.appspot.com/maps/documentation/utils/geocoder/#q%3D%26options%3Dtrue%26in_country%3DUS%26in_postal_code%3D42020
I hope this helps!
This worked for me. Only with zip code search.
verifyZipCode_google(zipcode) {
return this.httpClient.get(`https://maps.googleapis.com/maps/api/geocode/json?address=${zipcode}&components=postal_code:${zipcode}&region=us&sensor=true&key=${environment.GOOGLE_API_KEY}`);
}

Google Maps Geocoding - Results in different order

Trying to get the state from maps.googleapis.com/maps/api/geocode/xml is not working for me because not all results are in the same order
The problem is not all locations are the same, I'm using coordinates as the parameter in the urls, most are address_component[5], but the others put the state any and ever where else. The only thing that seems consistant is the formatted address.
See these 2 examples, the states are in different order
for one $xml->result->address_component[5]->short_name is the state
for the other $xml->result->address_component[4]->short_name is the state
https://maps.googleapis.com/maps/api/geocode/xml?latlng=38.7811981,-75.6823615&sensor=false
http://maps.googleapis.com/maps/api/geocode/xml?latlng=36.370791599999996,%20-76.75601170000002&sensor=false
There has to be a simple answer! Thanks

Google Maps: Norwegian postcodes not returning any results

Putting it simply, we have some Norwegian postcodes and are using the API to get their addresses and lat & long. Nothing to highbrow, but on around 10% of the postcodes. The API returns no results, here's an example:
Success for postal_code=1151:
http://maps.googleapis.com/maps/api/geocode/json?components=country:NO%7Cpostal_code:1151&sensor=false
Fail for postal_code=2066:
http://maps.googleapis.com/maps/api/geocode/json?components=country:NO%7Cpostal_code:2066&sensor=false
I have noticed that the majority appear to be for the Postboks (presuming equivalent of PO boxes in the UK).
However, it's not true for all of them.
Has anyone similar experience and or perhaps a better knowledge of Norwegian postcodes?
Thanks
I tried your given request, and I found that postal_code=2066 give you ZERO_RESULTS, If you are looking to the name Jessheim, am I right? Then I think you should use the postal_code=2069, this will give you the request that you want.
Here is the request that I used.
maps.googleapis.com/maps/api/geocode/json?components=country:NO|postal_code:2069&sensor=false
Also, I think you should know first the correct/available postal code that you used. I tried to request generally in which I did not set any country as a filter.
First, I used the postal_code=1151, and as you can see, you will find the 1151 Oslo, Norway address in the result. Which means the postal_code 1151 is available in Norway.
maps.googleapis.com/maps/api/geocode/json?components=country:|postal_code:1151
Second, I used the postal_code=2066, and you will not find any address that the country is NORWAY.
maps.googleapis.com/maps/api/geocode/json?components=country:|postal_code:2066
For additional note, if you use two components value in your request.
You need to use pipe(|) to separate them. I hope I help you with this
:)
KENDi - thanks a lot for your help and answer. I found out that Norway has two types of postcode. One is for the street addresses, the other is for postboxes (or PO Boxes in the UK) that don't have an geographical address.
Here's an example
http://adressesok.posten.no/en/postal_codes/search?utf8=%E2%9C%93&q=Molde

how to check the google map api to know the place is existing one

I have use the code given below, please copy and paste in your URL, which gives latitude and longitude of a specific place.
But when I have used the same call with wrong place it returns latitude and longitude. How to check whether it is right and wrong?
http://maps.google.com/maps/api/geocode/json?address=dubai+United+Arab+Emirates&sensor=false
http://maps.google.com/maps/api/geocode/json?address=anu+India&sensor=false
Thanks
A typical scenario for using geocoding will be when you know that the address exists and you want to get the location coordinates, maybe to mark on a map. When you search an address in google geocoding api, it will find exact matches and also partial matches to correct for cases like spelling mistakes or multiple spellings in use. Due to partial match, when you search for a word, words close to that in terms of the letters used and the number of letters present will also be found. You can explore 2 options to refine the results:
1, If you want to avoid partial matches , you can try component filtering , where you specify filters on components like locality, country , etc and only exact matches will be returned.
2, You can process the json result in your code by retreiving different components and doing comparisons and taking only cases matching your requirement.

Google Map GEO Results

I'm getting really frustrated with Google geo results and hope someone can advise me the best was to go.
I have created a AutoSuggest feature where you can start typing the address and Google will respond with suggestions. User then selects and address to move on.
But before I want them to continue on the next page I want to validate their selection. I would have thought this will be easy as we are only checking against what Google has already given. But when I do my validation lookup it displays no results.
Some example code:
Lets say I picked from the suggestion this address: Suffield, CT 06078, USA
Then on validation I do a second lookup with this address ie.
$string = "Suffield, CT 06078, USA";
echo 'http://maps.google.com/maps/geo?output=json&oe=utf8&gl=us&sensor=false&key=[MyKey]&q='.urlencode($string).'';
It gives me Error code 602 (G_GEO_UNKNOWN_ADDRESS)
How can it not be found when its given me the address?
How I can get around this?
You're right. That is quite strange.
Note that it does work when you remove the space between CT and 06078:
http://maps.google.com/maps/geo?q=Suffield,+CT06078,+USA&output=csv&sensor=false
The above returns 41.9817631,-72.6506462. (Link to Google Maps)
Reverse geocoding those coordinates with:
http://maps.google.com/maps/geo?q=41.9817631,-72.6506462&output=csv&sensor=false
returns:
200,4,"Suffield, CT, USA"
It's really strange, to be sure, but I was able to validate the address using the full state name.
Doesn't work:
http://maps.google.com/maps/geo?output=json&oe=utf8&gl=us&sensor=false&key=[MyKey]&q=Suffield,%20CT%2006078
Does Work:
http://maps.google.com/maps/geo?output=json&oe=utf8&gl=us&sensor=false&key=[MyKey]&q=Suffield,%20Connecticut%2006078
And yes, the address they provided to you doesn't work in their own system. That being said, searching for Hartford, CT DOES work. It appears there may be a listing discrepency in their data whereby Suffield + CT returns false results.