Google maps query parameter clarification - google-maps

I am implementing a feature in the website where I take the location of the users via 5 input boxes and then need to show location in the google maps,
I know this process is called geocoding but again after doing some search I came across this link,
http://www.seomoz.org/ugc/everything-you-never-wanted-to-know-about-google-maps-parameters
This link tells that we can pass location as query string parameters to google map's url.
Is this process valid and is their any restriction on its usage this way

The place I have always gone for Google Maps query parameters was this mapki page. Creating a URL for google maps is directing your user to google's website, and is subject to the terms of use for google maps.
See the link in the original question, the mapki link is dead.
content from Google Map Parameters (note this referred to the original http://maps.google.com, not to the "new" google maps, looks like it might have been originally authored by Mike Williams):
Google Map Parameters
From Google Mapki (no longer live)
Here's a list of some of the parameters that can be passed to maps.google.com. You might want to pass such parameters if you want to get Google Maps to display driving directions, which are not available under the API.
q= Query - anything passed in the q parameter is treated as if it had been typed into the query box on the maps.google.com page. In particular:
a precise address is looked up and a marker and info box is displayed at the specified point
a town name, or the first half of a postcode causes the region to be displayed with to marker or info box
an exact location can be specified as latitude,longitude, in decimal form (52.123N,2.456W or 52.123,-2.456) or as degrees, minutes and seconds (52 7 22.8N,2 27 21.6W or 52 7 22.8,-2 27 21.6) or as degrees and minutes (52 7.38N,2 27.36W or 52 7.38,-2 27.36).
any text added in parentheses () is displayed in the info window and sidebar in bold, there appears to be no way to cause a line break, but you can use %A0 as a "no break space" to prevent line breaks happening where you don't want them.
the words "to" and "from" cause the driving directions function to be activated.
the word "near" or "loc:" causes the local search function to be activated
space-ampersand-space (use +%26+ or %20%26%20 in URLs, not +&+ or +&+ otherwise the ampersand gets treated as a separator) can be used between the names of two streets to specify an intersection.
A location can also be specified after an at sign, in decimal form (#52.123,-2.456). This gives a lower zoom level than using the same values without the at sign. Using this format interferes with other options of the query parameter. The # sign instead of "near" or "loc:" tends to cause only a single business result to be displayed, compare (Church near Hallows Road Blackpool, Lancashire) which returns over 1000 results to (Church # Hallows Road Blackpool, Lancashire) which returns one result.
The full URL of a Google Earth .KML/.KMZ file or a RSS feed that includes GeoRSS data, can be used, and the contained information will be displayed on the map.
ll= Latitude,longitude of map centre - Note the order. Only decimal format is accepted.
If this is used without a query, then the map is centred at the point but no marker or info window is displayed
sll= Latitude,longitude of the point from which the business search should be performed. You could use this to perform an off-centre busness search. Google use it so "link to this page" can record a map that has had the centre moved after performing a business search.
spn= Approximate lat/long span. The zoom level will be adjusted to fit if there's no &z parameter. Use this Mapki tool to find a lat and long.
sspn= ?? lat/long of... what?
hl= Host language - only a few languages are supported, e.g. &hl=fr for French.
t= Map Type. The available options are "m" map, "k" satellite, "h" hybrid
saddr= Source address. Use this when asking for driving directions
any text added in brackets is displayed in the sidebar in bold
daddr= Destination address(es). Use this when asking for driving directions
any text added in brackets is displayed in the sidebar in bold
"+to:" clauses can be appended to the destination to request multiple destination routing, like this "&dadr=Blackpool+to:Manchester+to:Leeds"
text in brackets can also be added to the "+to:" clauses.
mrad= Additional destination address.
If you've got three points in your trip you can use &saddr, &daddr and &mrad instead of "+to:" clauses.
start= Skips the first (start-1) matches
num= Display, at most, this number of matches. The valid range is 0 to 10 (but 0 is a bit pointless).
near= Can be used as the location part of a query instead of putting the whole thing into &q.
f= Controls the style of query form to be displayed. &f=d displays the "directions" form (two input boxes: from, to), &f=l displays the "local" form (two input boxes: what, where). Otherwise the default search form is displayed (single input).
output=html Uses the old style Google Local page format from before it merged with Google Maps, with the small map and large sidebar.
output=js Outputs JavaScript object literals and function calls used by Google Maps, including encoded polyline data for driving directions, and stage information in HTML format.
output=kml Outputs a KML file containing full Placemark information representing the current map.
output=nl Outputs a small KML file containing a NetworkLink wrapper linking to a URL from which Google Earth and Google Maps can obtain the Placemark information.
latlng= This is a weird one. It takes three numbers separated by commas. The first two numbers (presumably representing latitude and longitude multiplied by 1000000) are ignored. The third number seems to be a Google internal "Company ID" number for a particular business. E.g. &latlng=0,0,14944637421527611642 represents Blackpool Community Church. Specifying this parameter performs a Google Search for pages that reference that business, and displays a tiny map. Other parameters, in particular &q, must have valid contents (but need not relate to the target business) for this to work.
cid= Similar to latlng, but generating a different map size. It takes three numbers separated by commas. The first two numbers (presumably representing latitude and longitude multiplied by 1000000) are ignored. The third number seems to be a Google internal "Company ID" number for a particular business. E.g. &cid=0,0,14944637421527611642 represents Blackpool Community Church. Specifying this parameter displays a large map of the identified company location. Other parameters, in particular &q, must have valid contents (but need not relate to the target business) for this to work.
vp= The presence of this parameter causes maps.google.com to switch into Copyright Service mode. Instead of returning the html that draws a map, it returns information about the copyright ownership in Javascript format. The &vp parameter specifies the viewpoint (i.e. the centre of the map). Copyright Service only works when the &spn and &z parameters are also supplied, indicating the span and the zoom. Optional parameters are &t, which specifies the map type, and &key which specifies the API key of the site performing the request. E.g. http://maps.google.com/maps?spn=0.030372,0.068665&z=6&t=h&vp=53.859462,-3.038235
om= The presence of this parameter with a value other than 1 causes the overview map to be closed. If the parameter is omitted, or present with the value 1, then the overview map is open.
ie= Can be used to specify the character set. e.g. &ie=UTF8.
pw= Activates print mode and initiates printing. There seems to be a problem at the moment with &pw=1, but using settings like &pw=2 is OK.
z= Sets the zoom level.
iwloc= Specifies where the infowindow will be displayed. In a business search &iwloc=A to &iwloc=J will open the info window over the corresponding business marker, and &iwloc=near will place it over the big green arrow if that's currently displayed. &iwloc=addr can be used on map search to explicitly request the info window to be open on the address, but that's the default anyway. Directions search supports &iwloc=start, &iwloc=end and &iwloc=pause1 etc.
layer=t Activates the traffic overlay
msa=b Activates the "My Maps" sidebar when used in conjunction with "maps.google.com/ms". It does nothing without the "/ms" and "/ms" does nothing without the "&msa=b".
msa=0 Involved in My Maps processing. Possibly specifies the My Maps server number.
msid= Specifies a My Maps identifier. When used in conjunction with "maps.google.com/ms" and &msa=0, the corresponding My Map is displayed.
mrt=kmlkmz Skips the normal search and goes directly to User-Created Content. Only works if the query contains a location and something to search for. E.g. q=hotel&near=london&mrt=kmlkmz or q=hotel+in+london&mrt=kmlkmz.
view= Can be used to select text view (view=text) or the normal map view (view=map)
dirflg=h Switches on "Avoid Highways" route finding mode.
Retrieved from "http://mapki.com/wiki/Google_Map_Parameters"

Yes, it's valid, here is the Google documentation
which also covers usage limitations

Related

Google Places Radar Search Leaving Out Some Results (not referring to detail information)

When doing a Radar Search for a specific Place Type (in this case "shoe_store") the API is not returning all (within the 200 limit) places with the type "shoe_store" in that radius. It is obtaining some beyond the radius, but leaving out some within. More specifically the following API search is the one I'm looking at now:
API CALL:
https://maps.googleapis.com/maps/api/place/radarsearch/xml?location=39.0923384,-76.8564899&radius=28967&types=shoe_store&key=APIKEY
Using a radius of 28,967 I should get "shoe_stores" within roughly a 18 mile radius. I specifically am looking to ensure I get "Shoe Show" and "Shoe Dept" of which there are 7 when one does a simple "Shoe Show near 14708 Baltimore Ave Laurel, MD 20707" in the regular maps.google.com site. However, when using the Radar Search only one of them shows up while other, further out, shoe stores show up.
Am I missing something in my API call or does the API simply prioritize results as it sees fit, skipping some and not staying within specified radius?

Removing the info window from an embedded map in the new Google Maps

In years past, it was easy to remove the info window from an embedded Google Maps. Just add iwloc=near in the query string.
In the past few weeks, Google has migrated to a NEW embed query string format, to coincide with their new Maps product.
Does anybody know how to hide the info bubble with the new query string? I do want to keep the marker icon (obstructed by the info window). I tried including iwloc=near before the rest of the query string, but that did nothing. I don't see any option on the new Embedded Map builder, either.
<iframe
src="https://www.google.com/maps/embed?iwloc=near&pb=!1m20!1m8!1m3!1d3246.3028987305834!2d-97.52973594999999!3d35.5462208!3m2!1i1024!2i768!4f13.1!4m9!1i0!3e6!4m0!4m5!1s0x87b21a2b843c4d5f%3A0xd6deac9724fb9935!2s7316+N+Western+Ave%2C+Oklahoma+City%2C+OK+73116!3m2!1d35.5462208!2d-97.5297267!5e0!3m2!1sen!2sus!4v1394217557679"
width="420"
height="200"
frameborder="0"
style="border:0">
</iframe>
Here is what is output. Note the info window, bordered in red, that I wish to remove.
It looks like they've overhauled the way the embedded maps api works...
From the new docs, it looks like you can definitely remove the bubble by making request in "view mode" instead of "place mode". However this will result in no marker either.
It doesn't have much to say on what options are supported for place mode, but you might try updating your URL to the new place endpoint and then experimenting with some of the legacy options.
Update
I tested it myself using the new google.com/maps/embed/v1/place/... endpoint and it doesn't work if you add &iwloc to that. In fact, it will throw an error about the unsupported parameter.
Unfortunately, it appears that the new API only supports these parameters:
The following optional parameters can be used with any of the map
modes listed above.
center defines the center of the map view. It accepts either a
comma-separated latitude and longitude value (such as
37.4218,-122.0840) or a place name or address string (such as Champ+de+Mars,Paris,France).
zoom sets the initial zoom level of the map. Accepted values range
from 0 (the whole world) to 21 (individual buildings). The upper limit
can vary depending on the map data available at the selected location.
maptype can be either roadmap (the default) or satellite, and defines
the type of map tiles to load.
language defines the language to use for UI elements and for the
display of labels on map tiles. Note that this parameter is only
supported for some country tiles; if the specific language requested
is not supported for the tile set, then the default language for that
tileset will be used. By default, visitors will see a map in their own
language.
region defines the appropriate borders and labels to display, based on
geo-political sensitivities. Accepts a region code specified as a
two-character ccTLD (top-level domain) value.
Sorry to be the bearer of bad news.
Try entering latitude & longitude coordinates instead of address. Was just now pleasantly surprised it generated the iframe code without address block overlay.

Simple geocoding example that loads an arbitrary address

All the "simple examples" of geocoding load a hard-coded long/lat pair and then, after the map is displayed, they load the arbitrary user-supplied address. Unfortunately for me, this means the hard-coded location always appears first and then the map shifts to the user-supplied address. What I'd like to find out is how to geocode an arbitrary address first, then initialize the map to the location in one step, so that when the map appears on the screen it is already showing the correct location.
I've been unable to deduce how this could be done from the API docs, however. All the examples show "new google.maps.Map()" being called prior to geocoding and it appears you have to already have a location to create the map, so it's impossible to geocode before displaying the map. On the other hand, it seems to me this would be the most common way to use a google map, so surely there's some way to do it?
Is this possible and does anyone have an example they could point to? Thanks!
If I understood you correctly, I created a simple page here
http://jsfiddle.net/4QGKq/1/
There's a hardcoded human readable address in the HTML ("Sardegna")
The geocoder figures out LatLng from Sardegna
Map is created and centered there.
To change the default map center, change the address in the Source HTML panel, not the textbox, then click on the blue "Run" button.

What is a good API to use to determine the address of a place based on its name?

I need to get the specific address (or lat/long coordinates) of a place based on that place's name.
Specifically, I need to determine the location of supermarkets in a given area so that I can use those locations as 'markers' in my implementation of google maps static maps api.
Using the following, I can if you input a specific location in the area that currently says "INSERT_LOCATION_HERE", then you will get a google map of the specified area with markers at the locations.:
http://maps.google.com/maps/api/staticmap?center=Ithaca,%20NY&size=512x512&maptype=roadmap&markers=color:blue|label:S|INSERT_LOCATION_HERE&sensor=false
For example (the marker indicates the local Wegmans store based on its address:
http://maps.google.com/maps/api/staticmap?center=Ithaca,%20NY&size=512x512&maptype=roadmap&markers=color:blue|label:S|500%20So.%20Meadow%20Street&sensor=false
If anyone knows how to do this without using google maps places api, that would be extremely helpful!
If you want to get the name as a string intead of an image, you can do it with a little help for Google. That'll match nicely with the static map that you're using.
Let's say you want to search for "Den Haag"...
Construct a URL like this, and parse the result:
http://maps.google.com/maps/geo?q=den%20haag
You can also specify the output format:
http://maps.google.com/maps/geo?q=den%20haag&output=xml
http://maps.google.com/maps/geo?q=den%20haag&output=csv
http://maps.google.com/maps/geo?q=den%20haag&output=json
You can also provide coordinates instead of a name, and get a full name+coordinates in return:
http://maps.google.com/maps/geo?q=52.0467315,4.3796239&output=json
For some reason the links don't work when you click them from this page. I guess google doesn't accept a referrer in the request, so just copy and paste the links... That works.

What parameters should I use in a Google Maps URL to go to a lat-lon?

I would like to produce a url for Google Maps that goes to a specific latitude and longitude. Now, I generate a url such as this:
http://maps.google.com/maps?z=11&t=k&q=58 41.881N 152 31.324W
The resulting map comes up with a round "A" balloon pointer, which seems to point to the nearest named object, and a green arrow, which points to the lat-lon. Sometimes, as in this example, the "A" pointer is centered and is far enough away that you cannot see the pointer to the lat-lon. (Zoom out to see both pointers in this example. The "A" pointer is in the center of Alaska, while the lat-long pointer is on Kodiak Island.)
Are there some parameters I can use in the Google Maps URL that will produce a single pointer to a designated lat-lon? (This loads in a separate window. It is not embedded.)
This is current accepted way to link to a specific lat lon (rather than search for the nearest object).
http://maps.google.com/maps?z=12&t=m&q=loc:38.9419+-78.3020
z is the zoom level (1-20)
t is the map type ("m" map, "k" satellite, "h" hybrid, "p" terrain, "e" GoogleEarth)
q is the search query, if it is prefixed by loc: then google assumes it is a lat lon separated by a +
yeah I had the same question for a long time and I found the perfect one. here are some parameters from it.
https://maps.google.com?parameter = value
q=
is used to specify the search query in Google maps search.
eg :
https://maps.google.com?q=newyork or
https://maps.google.com?q=51.03841,-114.01679
near=
is used to specify the location alternative to q=. Also has the added effect of allowing you to increase the AddressDetails Accuracy value by being more precise. Mostly only useful if query is a business or suchlike.
z=
Zoom level. Can be set 19 normally, but in certain cases can go up to 23.
ll=
Latitude and longitude of the map centre point. Must be in that order.
Requires decimal format. Interestingly, you can use this without q, in
which case it doesn’t show a marker.
sll=
Similar to ll, only this sets the lat/long of the centre point for a business search. Requires the same input criteria as ll.
t=
Sets the kind of map shown. Can be set to:
m – normal map,
k – satellite,
h – hybrid,
p – terrain
saddr=
Sets the starting point for directions searches. You can also add text into this in brackets to bold it in the directions sidebar.
daddr=
Sets the end point for directions searches, and again will bold any text added in brackets.You can also add "+to:" which will set via points. These can be added multiple times.
via=
Allows you to insert via points in directions. Must be in CSV format. For example, via=1,5 addresses 1 and 5 will be via points without entries in the sidebar. The start point (which is set as 0), and 2, 3 and 4 will all show full addresses.
doflg=
Changes the units used to measure distance (will default to the standard unit in country of origin). Change to ptk for metric or ptm for imperial.
msa=
Does stuff with My Maps. Set to 0 show defined My Maps, b to turn the My Maps sidebar on, 1 to show the My Maps tab on its own, or 2 to go to the new My Map creator form.
dirflg=
can set miscellaneous values below:
h - Avoid highway
t - Avoid tolls
reference
http://moz.com/ugc/everything-you-never-wanted-to-know-about-google-maps-parameters
In May 2017 Google announced the Google Maps URLs API that allows to construct universal cross-platform links. Now you can open Google maps on web, Android or iOS using the same URL string in form:
https://www.google.com/maps/search/?api=1&parameters
There are several modes that you can use: search, directions, show map and show street view.
So you can use something like
https://www.google.com/maps/search/?api=1&query=58.698017,-152.522067
to open map and place marker on some lat and lng.
For further details please refer to:
https://developers.google.com/maps/documentation/urls/guide
This should help with the new Google Maps:
https://maps.google.com/maps/place/<name>/#<lat>,<long>,15z/data=<mode-value>
The place adds a marker.
name could be a search term like "realtors"/"lawyers".
lat and long are the coordinates in decimal format and in that order.
15z sets zoom level to 15 (must be between 1 ~ 20).
You can enforce a particular view mode (map is default) - earth or terrain by adding these:
Terrain: /data=!5m1!1e4
Earth: /data=!3m1!1e3
E.g.: https://www.google.com/maps/place/Lawyer/#48.8187768,2.3792362,15z/data=!3m1!1e3
References:
https://moz.com/blog/new-google-maps-url-parameters
http://dddavemaps.blogspot.in/2015/07/google-maps-url-tricks.html
The following works as of April 2014. Delimiting each component of the URL with + and & for spaces and addition statements, respectively.
Full HTML:
<iframe src="http://maps.google.com/maps?q=Scottish+Rite+Hamilton+ON&loc:43.25911+-79.879494&z=15&output=embed"></iframe>
Broken down:
http://maps.google.com/maps?q=
where ?q= starts the general search, which I provide a venue, city, province info using + for spaces.
Scottish+Rite+Hamilton+ON
Next the geo-data. Lat and lng.
&loc:43.25911+-79.879494
Zoom level
&z=15
Required for iframes:
&output=embed
http://maps.google.com/maps?q=58%2041.881N%20152%2031.324W
Just use the coordinates as q-parameter. Strip the z and t prameters. While z should actually just be the zoom level, it seems that it won't work if you set any.
t is the map type. Having that said, it's not obvious how those parameters would affect the result in the shown way. But they do.
Maybe you should try the ll-parameter, but only decimal format will be accepted.
You can find a quick overview of all the parameters here.
If you need a name on your pin, you can also use:
http://maps.google.com/?q=MY%20LOCATION#lat,long
All the answers didn't work for me (the loc: and # options). So here is my solution for the new Google maps (April 2014)
Use the q= for query description, for example the street or the name of the place.
Use ll= for the lat, long coordinates.
You can add extra parameters like t=h (hybrid) and z=19 (zoom)
https://maps.google.com/?q=11+wall+street+new+york&ll=40.7060471,-74.0088901
https://maps.google.com/?q=new+york+stock+exchange&ll=40.7060471,-74.0088901
https://maps.google.com/?q=new+york+stock+exchange&ll=40.7060471,-74.0088901&t=h&z=19
There have been a number of changes, some incompatible, since I asked this question 5 years ago. Currently, the following works properly:
https://www.google.com/maps/place/58°41.881N 152°31.324W/#58.698017,-152.522067,12z/
The first latitude/longitude will be used for the pin location and label. It can be in degrees-minutes-seconds, degrees-minutes, or degrees. The second latitude/longitude (following the "#") is the map center. It must be in degrees only in order for the zoom (12z) to be recognized.
For terrain view, you can append "data=!4m2!3m1!1s0x0:0x0!5m1!1e4". I can find no documentation on this, though, so the spec could change.
New Version queries have a different format
To reach a lat long by url use (e.g.)
https://www.google.com/maps/search/-15.924,-5.719
works fine
https://maps.google.de/maps?q=51.404989,13.091751&z=17&t=k
This doesn't have to be much more complicated than passing in a value for the 'q' parameter. Google is a search engine after all and can handle the same stuff it handles when users type queries into its text boxes
"maps.google.com?/q=32.5234,-78.23432"
This works to zoom into an area more then drop a pin:
https://www.google.com/maps/#30.2,17.9820525,9z
And the params are:
#lat,lng,zoom
If you only have degrees minutes seconds you can pass them on the url :
https://maps.google.com/maps?q=latDegrees latMinutes latSeconds longDegrees longMinutes longSeconds
substitute in %20 for the spaces
"ll" worked best for me, see:
http://mapki.com/wiki/Google_Map_Parameters (query reference)
it shall not be too hard to convert minutes, seconds to decimal
http://en.wikipedia.org/wiki/Decimal_degrees
for a marker, possibly the best would be ?q=Description#lat,long