Google Maps geocode api inconsistencies - google-maps-api-3

I'm trying to geocode this address "188th street & third avenue, bronx NY"
If you run this geocode query through the maps api v3 geocoder, you get back 10 or so results, none of which are in new york.
http://maps.google.com/maps/api/geocode/xml?sensor=false&address=188th%20street%20&%20third%20avenue,%20bronx%20NY
If you paste that same address into google maps, it takes you directly to the intersection in the bronx.
Is there a reason these results are inconsistent, and is there a way I can get the geocoder to give me the correct result, or at least something in the same state?
(at first i thought it was because 'third' was spelled out, so i replaced it with '3rd'. I still got 10 results with one in NYC. however, it was in queens instead of the bronx.)

The problem is that you do not URL-encode & in the address and use it as it is. But this & is used for separation of URL arguments as e.g. between sensor=false&address=. So, the data beyond & is not considered to be part of the address. You need to replace & in the address argument by its URL-encoding %26:
http://maps.google.com/maps/api/geocode/xml?sensor=false&address=188th%20street%20%26%20third%20avenue,%20bronx%20NY
and you will get the one correct location in New York, Bronx:
<location>
<lat>40.8588700</lat>
<lng>-73.8911250</lng>
</location>
Just for information: the Google geocoding web service uses + for spaces in the address. Also, the recommended service URL is http://maps.googleapis.com/maps/api/geocode/. So, you could issue as well the query:
http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=188+street,%26+third+avenue,+bronx+NY
which appears a bit simpler.

Related

Getting RefererNotAllowedMapError from GAPI whereas the restriction pattern defined seems to match the referring URL

A.S/ probably for another SE.com site: why "referer" is spelt with only r at Google's?
Anyway, here we go again with another occurrence of RefererNotAllowedMapError.
I couldn't find my answer in the existing Q&As.
Hypothesis:
I have a local website that includes a GMap.
It displays and works
fine provided I remove all restrictions on that key, from the Google
API console.
But the browser will receive a Google Maps JavaScript
API error: RefererNotAllowedMapError whenever I add a referrer
restriction, which seems to match the refering URL.
The referrer, where the map is being called form, is:
https://app.developr.online.local/projects?p=name-asc-0-20-1&a=createProject
Below is my GAPI KEY security configuration:
Below is the corresponding console output:
To be noted:
If I add a trailing asterisk when declaring the referer, validating that entry will clear it anyway. To me it means: "that's ok, we're covering trailing /* already.".
My question: what pattern should I enter as a referrer (2 r's) to have it recognised by GAPI security layer?
I've tried a few things, I didn't get a cigar.
Thank you.

Get post code from getlinkinfo

Is there a way to get the post code as part of the address returned by the getlinkinfo resource of the routing API? Example:- http://route.st.nlp.nokia.com/routing/6.2/getlinkinfo.xml?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&waypoint=50.05564304861044,8.38889128575724&linkattributes=all returns street, city, country but not postcode
You can use the HERE Geocoder API and do a reverse geocode for the position. This will get you the postal code among other location information and link attributes (locationattributes=linkInfo). The last option is new since this week. Let me know if this helps or what exactly you are trying to do and what response details you need.
Following is an example call:
http://reverse.geocoder.cit.api.here.com/6.2/reversegeocode.xml?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&gen=8&maxresults=1&mode=retrieveAddresses&prox=50.05564304861044%2C8.38889128575724%2C250&locationattributes=linkInfo

How to construct complex Google Web Search query?

Searching through the Web by using the Google search engine is a de facto standard for Internet users.
Google provides a basic or an advanced form to prepare a query string to its search engine. Supposing to be interested in not using the web form, one can simply do an HTTP get request to the specific URL with a query string constructed upon the search conditions.
For instance I can search for results with word "hello" by doing an HTTP request at:
http://www.google.com/search?q=hello
I can add another word, e.g. "world", as follows:
http://www.google.com/search?q=hello+world
You know, the search can be more "complicated" by specifying nice parameters like:
or condition(s)
exact phrase(s)
search on specific domain(s)
avoid a specific word(s)
search with a specific language
limit search by geographical area
search for document type
etc.
How can I modify the query string to account for the above search parameters?
I carefully examined the answers by Pratik Chowdhury and Robbie Vercammen. They provides a link to Web documents that report a list of possible textual filtering to be used within the Google search form. Despite this is interesting, they don't provide an answer to the question. Hence, I studied a lot the problem and I found the following solution.
Suppose that you need to make a una tantum HTTP call (e.g. by a PHP class runned via CRON once a month) to Google Search in order to retrieve the search results for a particular string query, e.g. all the pages with some words (i.e. "hello" and "world") in your website (i.e. mywebsite.com), then you can do an HTTP get call to the following address:
http://www.google.com/search?q=hello+world+site:mywebsite.com
The q parameter can contain the whole search query, however Google defined a dummy proof list of parameters.
Notice that the AND operator can be represented by the as_q parameter instead.
To get page results with one between "hello" and" world" (i.e. and OR), must be changed the query "q" parameter as:
q=hello+OR+world
while a more compact representation uses the as_oq parameter:
as_oq=hello+world
If one looks for the exact phrase "hello world", the q parameter is:
q="hello+world"
while, again, another compact representation uses the as_epq parameter:
as_epq=hello+world
If one looks for all the results that not contain the words "hello" and "world", the q parameter is:
q=-hello+-world
while, again, another compact representation uses the as_eq parameter:
as_eq=hello+world
Of course, as_q, as_oq, as_epq, as_eq, etc. can by combined in a unique search query as usual (i.e. by using the & character). Thus, for instance I can search for both words "hello" and "word" plus one between "programming" and "code" as follow here:
q=hello+world&as_oq=programming+code
One can search for a specific domain (again, mydomain.com) as follow:
as_sitesearch=mydomain.com
However, if you want to exclude a specific domain (e.g., because it is a spam source), you must recur to standard notation. E.g.:
q=hello+-site:mydomain.com
return all the pages with word "hello" that are not in site mydomain.com.
To get for a specific file type, e.g. a pdf, you can use as_filetype:
as_filetype=pdf
More complex search parameter can be used, as provided in Google support docs.
For instance, to get also results with a synonym of a word, simply use the ~ operator in front of the word, e.g.
q=~hello
Moreover, if you want to use wildcards, e.g. to get all the exact phrases that start with "hello" and end with "world", you should use the * operator:
q="hello+*+world"
which probably will return something like: "hello to the world" and "hello sweet world".
One can also search for specific words inside the page title or in the page url by using the following keywords (read here for more details):
intitle
allintitle
inurl
allinurl
For instance, the following returns all the pages s.a. both words "hello" and "world" are in the url:
q=allinurl:hello+world
For the language of the Google GUI page (not the one of the results), one must insert into the query string the language string (e.g. en for English, fr for French, it for Italian, etc.) to the hl parameter. In other words, if one search with the English version of Google, the query string becomes as follow:
http://www.google.com/search?hl=en&q=hello+world+site:mywebsite.com
To select a specific language, e.g. Italian, use the lr query parameter:
lr=lang_it
One can also select pages published in a specific geographical region by using the cr parameter. E.g., to find all the pages published in Italy:
cr=countryIT
To create complex and / or queries, you can use () and OR.
For example if we want to search for
("tschakk buff" AND "boom bang") OR ("zata tong" AND "zong klirr")
The query would look like this:
https://www.google.com/search?q=("tschakk%20buff"%20"boom%20bang")%20OR%20("zata%20tong"%20"zong%20klirr")
though this books title seems dangerous but anyway it will answer all your questions if u don't misuse it.
The name of the book is "Dangerous Google – Searching for Secrets" by Michał Piotrowski by some hackin9 magazine.
Wish ya luck
If you are trying to assemble your own url by manually typing the url before using it, this site should prove helpful: http://www.googleguide.com/advanced_operators.html
Advangle is a nice free service where you can construct web-search queries visually and get a query string (or URL to Google and Bing) as the result.

Google Geocode API "REQUEST_DENIED" in JSON response - reverse geocode action

Looked everywhere — and have read dozens of other questions regarding Google APIs (Maps, Geocode, Places, Autocomplete, etc) — and nothing has worked.
I have an API key with Places, Static Maps, and Maps v3 & v2 services enabled.
I am trying to perform a reverse geocode (get street address information via JSON from lat/long coords).
Here is the URL I am passing in my JavaScript (last 5 digits of API key replaced with #####:
http://maps.googleapis.com/maps/api/geocode/json?latlng=49.8925136,-97.1466635&sensor=true&key=AIzaSyDbfv8bFidX1hSbXwwKTTxWQYgU7g####
The JSON response is:
{
"results" : [],
"status" : "REQUEST_DENIED"
}
As you can see, there is a "sensor=true" parameter being passed - which is the problem according to the Google Document supporting this API, but that is clearly not the case here.
I also tried passing simply
http://maps.googleapis.com/maps/api/geocode/json?latlng=49.8925136,-97.1466635&sensor=true
which returns expected JSON response when the URL is entered into the addressbar of a browser — but when added to the JavaScript in my HTML file, I again receive:
{
"results" : [],
"status" : "REQUEST_DENIED"
}
Any assistance is welcome, and greatly appreciated.
Google don't particularly want you to use this static API in a web page. You should be using the Maps API in a web page, and its associated geocoding functionality (because you need to show the results on a map anyway). These static APIs are intended for use server-side, so it looks like they now refuse requests which come with an HTTP_REFERER header.
(Using the key server-side allows you to keep track of statistics, but an invalid key will always result in REQUEST_DENIED whether there is a referrer header or not.)
I kept struggling with the exact same problem and I believe I came up with a very practical solution, which actually works just fine with me! You just have to make a small modification to your request query's URI.
Instead of querying the
http://maps.googleapis.com/maps/api/geocode/json?latlng=49.8925136,-97.1466635&sensor=true
you should actually query the google maps api using the following URI:
http://maps.google.com/maps/api/geocode/json?latlng=49.8925136,-97.1466635&sensor=true
That small modification did the work for me like a charm!
Hope this helps.

QUrl Class's *addQueryItem* method

I want to query the Google map for all the roads leading to a given GPS coordinate.
For that I'll have to place a "query" which can be done by: http://doc.qt.io/qt-4.8/qurl.html#addQueryItem
Now I want to know how to figure out that what should be the key and its corresponding value here?
Should the key be "road"/"roads"? Whats the way to decide that? And I want all the roads not a particular one!
Any hints?
An HTTP URL has the following format:
http://some/address?key=value&more=values
The part behind the '?' is your query. You have to determine how the resulting URL should look like and add key/value pairs accordingly.
It isn't completely clear to me what you want to accomplish. You might want to check out these Google Maps API Links:
http://code.google.com/intl/de/apis/maps/documentation/staticmaps/#Addresses
http://code.google.com/intl/de/apis/maps/index.html

Resources