Google Maps API US County Outline KML Files
The following 54 files, one for each state plus territories AS, PR, VI, are used on the HMdb.org website to show overlay county outlines on Google Map pages using the Google Maps API.
The reason the website uses 54 separate files rather than one for the entire USA is that Google Maps API has limits that a single KML file would exceed. Website code switches in the correct file for the original primary focus of the map. Because the county outline overlay is translucent and obscures the map, a “show/hide county outline”user control allows for them to be turned on and off.
This is not obvious and should be pointed out to the user in a map legend: click anywhere within a county outline to get an info-window showing the county’s name. Also, the show/hide control should differentiate between “counties” used for most states and Louisiana’s “parishes”, Alaska’s “boroughs” and Puerto Rico’s “municipalities.” Finally, suppress the show/hide control when DC is the original primary focus of the map (DC has no counties) or when any other country for which no county overlay files are available is the original primary focus of the map.
These outlines were sourced from Google Fusion Tables service. This service will no longer be available after December 3, 2019. We understand that Google Maps API customers will continue to be authorized to use these KML files for use with Google Maps.
The following line of JavaScript code inserts and displays the county outline layer on the map:
var countyLayer = new google.maps.KmlLayer({url: 'https://www.hmdb.org/CountyOverlay/UScountyOH.kml'}, map:map);
and the following lines hides or shows the layer:
countyLayer.setMap(null);
countyLayer.setMap(map);
Remove “,map:map” to insert but not display the overlay until .setMap(map) is used. Add “,preserveViewport:true” to prevent the map from zooming out to show the whole state every time the overlay is displayed.
###