Gain control of your links to Google Maps by understanding the URLs.
"Share Google Maps" [Hack #6] showed how to have Google Maps generate a link (i.e., Uniform Resource Locator or URL) that creates a view of the current map. A little exploration of Google Maps URLs can provide a lot of power!
We have no particular inside information, so much of what followsespecially what I think the abbreviated names stand foris just semi-knowledgeable guesses. Let's start with a basic URL. This is what you get if you search for Key West, Fl and then click on "Link to this page."
http://maps.google.com/maps?q=Key+West,+Fl&hl=en
The http://maps.google.com part should be familiar. This is the basic Google Maps address. Next, /maps is a program running on Google's servers that generates maps. Web programs can accept parameters. The syntax for parameters is to start with a question mark and then put the name of a parameter, an equal sign, and the value of the parameter. If you need a second (or third, or more) parameter, you put an ampersand between the first value and the second parameter's name. So ?q=Key+West,+Fl&hl=en means there is a parameter named q with the value Key+West,+Fl and a parameter named hl with the value en.
|
The parameter hl is the language for the results, and q is the query, or location that you are searching for. If you speak French, replace the en with fr, and so on. If you leave off the hl parameter, Google Maps will try to display things in whatever language the user's web browser prefers.
The q or query parameter can be any of the things that are discussed in "Find Yourself (and Others) on Google Maps" [Hack #2]. For example, here is the URL to a map for latitude 38 degrees north, longitude 122 degrees west:
http://maps.google.com/maps?q=38,-122&hl=en?
|
Here, for example, is ZIP Code 94305:
http://maps.google.com/maps?q=94305&hl=en
The query string for driving directions matches what you would enter into the search box, which is just as you'd expect. Here is San Francisco International (SFO) to Los Angeles International (LAX):
http://maps.google.com/maps?q=SFO+to+LAX&spn=3.984375,6.894949&hl=en
The spn parameter shows how much territory the map spans. It appears to be the number of degrees of longitude and latitude (in that order) that are shown on the map. The first value appears to be the number of degrees of longitude that are shown to the left and right of the center of the map. The second value is the same for the number of degrees of latitude that are shown above and below the center point.
For example, if the values are 1,1, then about 2 degrees of longitude (about 90 miles from east to west), and about 2 degrees of latitude (around 138 miles from north to south) are shown on the map.
When you search for driving directions, the span of the map is automatically set so that both the starting and ending points are shown. The span sets the zoom level. The fully zoomed-out map has a span of 63.750000, 110.319191, while the fully zoomed-in map is 0.003891, 0.006733 (at least for one sample mapit is likely that this varies with latitude). At this point it doesn't appear that you can manually enter an even smaller span. The system seems to have a minimum, beyond which it will not go.
|
1.8.1. More Parameters!
Table 1-2 lists the parameters we've been able to figure out. Here, for one example, is a search for "pizza" when the span of the map has already been limited to a local area:
http://maps.google.com/maps?q=pizza&sll=38.402193,-122.829009&sspn =0.031128,0.053867&hl=en
The parameter sspn appears to be the search span, and sll is the search's latitude, longitude center pointso this query is looking for pizza within .031128 degrees of longitude and .053867 degrees of latitude from latitude and longitude 38.402193, -122.829009.
For linguistic reasons, we tend to think latitude and then longitude (i.e., lat/long), but when we draw graphs we think x,y. Latitude maps to the y axis, so to be consistent we'd talk about either y,x graphs or latitude, longitude coordinates. Google appears to have adopted both conventions in expressing geographic coordinates in this URL. People are not consistent, and Google can happily have a URL that specifies the center point as latitude, longitude but the span in x,y.
To see the satellite view, add the parameter and value t=k. Maybe that means type is k? What could k mean? (keyhole, perhaps?) As of August 2005, the letter k and the number 1 both cause a satellite map to appear, and the letter h causes hybrid maps to appear. From experimentation (i.e., trying all the other letters), no other special tricks live in the t parameter. Perhaps the other letters and digits will be used for coming features.
This URL represents a satellite view and driving directions from SFO to LAX:
http://maps.google.com/maps?q=SFO+to+LAX&spn=5.603027,7.481689&t=k&hl=en
Or, to get just the driving directions:
http://maps.google.com/maps?q=SFO+to+LAX&spn=3.984375,6.894949&hl=en
Parameter |
Example |
Description |
---|---|---|
q |
94305 38,-122 |
Query string. This is what goes into the single search box. |
hl |
en fr |
Language. |
t |
h k 1 |
Imagery type. Show satellite imagery if set to k or 1 and hybrid maps if set to h. |
ll |
-122.7 38.4 |
Longitude and latitude of the center point of a generated map. |
z |
3 |
Zoom level. Ranges from 3 to 18. |
spn |
5.603027 7.481689 |
Number of degrees of longitude and latitude across the entire map. |
sspn |
0.031128 0.053867 |
Search span. Define area to search for local search. Same format as the spn parameter. |
sll |
38.403193 -122.82709 |
Search latitude and longitude. The center point for a local search. |
1.8.2. Finding More Parameters?
Another cute thing you can do with Google Maps queries is to add a custom title to the location by putting the title in parentheses after the search location. For example, the following URL shows the location of Google's headquarters, titled with the word "Google":
http://maps.google.com/maps?q= 1600+Amphitheatre+Parkway,+Mountain+View,+CA+94043+(Google)
Google Maps is filled with hidden (to us) options. The way to find out what it can do is to experiment! Try different things and to see what it all means, click on "Link to this page" often! You never know what might workthat is the essence of hacking!
1.8.3. See Also
You Are Here: Introducing Google Maps
Introducing the Google Maps API
Mashing Up Google Maps
On the Road with Google Maps
Google Maps in Words and Pictures
API Tips and Tricks
Extreme Google Maps Hacks