At work I play around with plotting interest levels for both our prospective students and our applicants. I have numerous scripts that I run that plot high school locations, zip code locations, individual address locations, etc. I recently was searching around for a county line map based on what you are able to do with your geocache finds (see here).
Well, I don’t format the data I pull from work into a GPX so that wouldn’t really work and I wanted to automate the process w/o having to play around with curl… So I located the shape files available from the 2000 Census and used an OSS utility to convert shape files to KML (used with Google Earth).
This OSS shp2kml utility was a bit cumbersome and I didn’t feel like having to futz around with installing Java at work, etc. I instead found another utility that does shp2kml and used that with great success.
After I got a decent KML out of the utility, I tried to load it into Google Maps via the search bar but found out that it was entirely too large to load in that way. I zipped the KML, creating a KMZ and then it was small enough to load (see here for an example — it can take a while to load and may require you to zoom or reload to see properly).
Next I needed to figure out how to use it with the Google Maps API. There are some undocumented API features that you can access in order to play the KMZ overlay on top of other points. It took me a little while but I did end up figuring it out.
The result can be seen here. This *will* take a while to load as there are 100s of points to plot for MN and WI.

Related posts:








February 26th, 2007 at 9:48 am
I guess, due to all the searching for this topic, that I should post the code on how to do it:
function GV_Map() {
if (GBrowserIsCompatible()) {
// === Create the tilelayer ===
var tilelayer = new GTileLayer(new GCopyrightCollection(), 0, 17);
// === Set the getTileUrl to use the Google KML tile processor with our KML file ===
tilelayer.getTileUrl = function(a,b) {
b=this.maxResolution()-b;
return
“http://maps.google.com/mapsdt?id=
http://lazylightning.org/mncounties-sorted.kmz
&x=”+a.x+”&y=”+a.y+”&zoom=”+b;
}
tilelayer.isPng = function() {return true;}
gmap = new GMap2(document.getElementById(”gmap_div”)); // create map
var initial_zoom_level = 6; // higher number means closer view; at 600px wide, 7 = width of New Mexico, 12 = $
gmap.setCenter(new GLatLng(45.7758475,-92.2703595), initial_zoom_level, G_NORMAL_MAP);
gmap.addControl(new GV_MapTypeControl()); // add custom map type switcher
gmap.addControl(new GLargeMapControl());
gmap.addOverlay(new GTileLayerOverlay(tilelayer));
_mSvgEnabled = true; _mSvgForced = true;
July 9th, 2007 at 2:58 pm
Thanks for the info. I am greatful. i tried to use your js code with some a kml generated with the tool you suggested. The kml does load fine in Google earth. but when I tried it with the js code in Google map, I see that variable a is creating a problem, perhaps because it is not defined.
Any help would be greatly appreciated!
Thanks