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. Update (10/3/08): I have removed this information from my site because I no longer work there and there are probably better ways to go about doing this.

Related posts:
Dakota Inmate Dashboard







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
April 15th, 2010 at 9:25 pm
I realize this is an old post, but thank you, it was a lot of help to me today. I went from knowing next to nothing about this to getting a (semi) working map in one day.
I still have one issue though, and wondering if you can give me a quick point in the right direction. I’m only working with 6 counties in CA, but my kmz file is 10 times as large as yours. In the census data, each county is divided into a number of smaller areas so there are a lot more coordinates than I need. I’m wondering how you got the coordinates for just the boundaries of the county from that. See attached image, this worked fine when I had 2 counties, but with all 6, it stopped showing most of the shading.
Not really expecting an answer, but still wanted to say thanks, if I was in MN I’d buy you a beer.
April 15th, 2010 at 10:32 pm
Jim,
1. I got the .e00 files from here: http://www.biogeog.ucsb.edu/projects/gap/gap_data_state.html and then tried to convert them to SHP using the instructions here: http://freegeographytools.com/2007/converting-e00-vector-data-to-shapefiles-a-free-and-fairly-painless-approach
I got the shape of CA’s county boundaries but the KML wasn’t plotting correctly. Maybe you can play with it from there.
2. This guy says you can get the SHP files for all the counties in the country: http://www.gelib.com/us-counties.htm and you could weed them out from there.
3. Try the Federal Government’s repository for all of these: http://dds.cr.usgs.gov/pub/data/nationalatlas/countyp020.tar.gz
—
Sorry I couldn’t have been of more help. Good luck.
April 16th, 2010 at 12:37 pm
You were a tremendous help, I got it working with the data from #3. Thanks again.
April 16th, 2010 at 12:38 pm
Glad to hear it Jim. Take care.