Friday, March 28, 2008

Google mapdata API Parameters Explained

Google has a simpler API to get map images and overlay markers as well. I think this is not part of the Google maps API, but nevertheless here's what I found...



Here's an example URL, mapping pizza outlets in Bangalore, India. The URL can be seen by accessing the new mobile search page of Google. The URL looks like this:

http://maps.google.com/mapdata?tstyp=4&latitude_e6=12982873&longitude_e6=77599426&image_format=1&w=285&h=165&cc=us&client=mobilefe-internal&zl=4&Point=b&Point.latitude_e6=12971606&Point.longitude_e6=77594376&Point.iconid=17&Point=e&Point=b&Point.latitude_e6=12980989&Point.longitude_e6=77602120&Point.iconid=18&Point=e&Point=b&Point.latitude_e6=12970048&Point.longitude_e6=77606600&Point.iconid=19&Point=e&Point=b&Point.latitude_e6=12970048&Point.longitude_e6=77606600&Point.iconid=20&Point=e&Point=b&Point.latitude_e6=12970048&Point.longitude_e6=77606600&Point.iconid=21&Point=e&Point=b&Point.latitude_e6=12990345&Point.longitude_e6=77589139&Point.iconid=22&Point=e&Point=b&Point.latitude_e6=12987049&Point.longitude_e6=77594915&Point.iconid=23&Point=e&Point=b&Point.latitude_e6=12972107&Point.longitude_e6=77606617&Point.iconid=24&Point=e&Point=b&Point.latitude_e6=12989932&Point.longitude_e6=77592090&Point.iconid=25&Point=e&Point=b&Point.latitude_e6=12974707&Point.longitude_e6=77609712&Point.iconid=26&Point=e


Some parameters are simple to understand:

w: width of the image
h: height of the image
zl: zoom level 1-9
image_format: 1,2 or 3 for gif,png and jpeg respectively


Few parameters that I'm not sure about:

tstype: font size? image quality?
cc: country?
client: type of browser?


Now coming to the coordinate specification. Coordinates are specified by the various latitude_e6 and longitude_e6 parameters. The first occurrence of latitude_e6 and longitude_e6 specify the map center point. Each point of interest to be marked in the map is wrapped by a begin and end marker.

begin: Point=b
end: Point=e


Each such point to be marked has a latitude and longitude and marker icon type.

Point.latitude_e6: lat of the point
Point.longitude_e6: long of the point
Point.iconid: the icon id to use

13 comments:

mvalenci said...

lat is usually a double from -180 to +180 and lon is from -90 to +90.
your capture of lat/log does not seem to be close to that.
please advise

tan said...

You are right mvalenci. In the URL by latitude_e6=12982873 Google means it is 12° 98' 28.73 seconds. Similarly longitude_e6=77599426 means it is 77° 59' 94.26 seconds. Bangalore is roughly 12°58'N and 77°38'E.

mvalenci said...

i actually think it's decimal degrees.
btw, tstype is map type

tan said...

Of course it must be decimal. There can't be 98 minutes! Silly me.

Yes tstyp indeed seems to be the map type as a bitmap.

Anonymous said...

tstyp
1: map
2: satellite
3: satellite + labels
4: only labels?
5: map (same as value 1)
6: terrain + labels

Anonymous said...

tstyp
1: map
2: satellite
3: satellite + labels
4: only labels?
5: map (same as value 1)
6: terrain + labels

Anonymous said...

Tan - In your examples, you manage to convert the lat/lon from the single number into it's component degress/minutes/seconds, but I can't see how this works with the following example:

Point.latitude_e6=53800174
Point.longitude_e6=4293415930

As an example, this is the city centre of Leeds, UK (Lat:53.800174, Lon:-1.551068)

Anonymous said...

Anonymous:

This is a case of a 32-bit signed integer value being put in the url as if it was an unsigned value.

To get the signed value you can use the following PHP:

echo - ((~4293415930 + 1) & 0xffffffff);

This gives the value -1551365.

Putting this into the url also displays Leeds, so the values appear to be interchangable.

Irene said...

Do you know if there is a way tu put into the map the labels to control the map type?
Thanks

Markus said...

tstyp
1: map + labels
2: satellite
3: satellite + labels
4: maps + labels
5: map + labels - private ground labels
6: terrain + labels
7: terrain + labels - private ground labels
8: national/international boundaries only
9: terrain + national/international boundaries

Irene said...

Anybody knows if there a new value for the parameter tstyp for Google Earth?
Thanks
Irene

Anonymous said...

Hey!!! did google just remove support for this API hack?!

Anonymous said...

Hey!!! did Google just remove support in this API or am i missing something ?