Rumsey Family Pages
You are currently anonymous Login
 

HomeHome    SearchSearch    PrintPrint    Login - User: anonymousLogin   

US County Boundaries
While not really a TNG mod, I thought others might benefit from these files that contain latitude/longitude based polygons of all US counties. I use this to outline county locations on my maps... I found it difficult to see where a county begins and ends without some sort of overlay on the Google map (click here for an example), but imagine there are lots of things folks could use this for.

If you like this mod, be sure to check out my others here.

The Files
The files are seperated into state directories (abbreviated with the two letter postal abbreviation) and can be found in the 'counties' directory. Each file is named county.xml (all special characters and spaces have been removed from the filenames.). The .xml files are of the format:

<boundary>
 <polygon>
  <pt lat="latitude1" lng="longitude1" />
  <pt lat="latitude2" lng="longitude2" />
  ....
  <pt lat="latitude1" lng="longitude1" />
 </polygon>
</boundary>

The first and last points should always be the same, ensuring an enclosed polygon. Note also that there are some cases where there are multiple polygons for a single county.

How To Use It
You're free to use the files however you'd like, but if you wish to use this with the TNG integration of Google Maps, just follow these instructions:

1) Download the uscounties.zip file. This contains all of the .xml files in a directory called 'maps'. Unzip this into the top directory of your website.

This should create the following directory structure on your site:

    maps/state/counties/county.xml

2) Override the googlemaplib.php and googlemaplib2.php in the googlemaps directory of your website with those in the counties_addon.zip file. Use the download section below to find the correct set of files for your version of TNG.

3) You will need to make a small edit to the placesearch.php file to define the "cfile" property of the map hash. There are many different ways that you may wish to set the $map[cfile] value... I've shown two ways below:

- The following addition will allow you specify the county file to be drawn by adding the line "cfile:" to the Notes field for the place.

$mapdrawn = false;
while( $prow = mysql_fetch_assoc( $presult ) ) {
    if( $prow[notes] || $prow[latitude] || $prow[longitude] ) {
      if (preg_match("/cfile:(\S+)/", $prow[notes], $match)) {
          $map[cfile] = $match[1];
          $prow[notes] = preg_replace("/cfile:\S+/", '', $prow[notes]);
      }
        if( ($prow[latitude] || $prow[longitude]) && $map[key] && !$mapdrawn ) {

For example, to draw the border of Burke Co., NC, you add the following line to the Notes field for that place:

cfile:maps/nc/counties/burke.xml

- This next method determines the XML file by parsing the location name (it assumes a place syntax which abbreviates County to "Co." and two letter state abbreviations):

$mapdrawn = false;
while( $prow = mysql_fetch_assoc( $presult ) ) {
    if( $prow[notes] || $prow[latitude] || $prow[longitude] ) {
      if (preg_match("/^(.*) Co\., (\S+)$/", $psearch, $matches)) {
        $state = strtolower($matches[2]);
        $county = strtolower($matches[1]);
        $mapfile = "maps/$state/counties/$county.xml";
        if (is_file($mapfile))
          $map[cfile] = $mapfile;
      }
        if( ($prow[latitude] || $prow[longitude]) && $map[key] && !$mapdrawn ) {

As you can see, it's just a matter of getting the $map[cfile] variable set to the path of the .xml file for that particular county. Exactly how you do it will depend on your particular situation.

Download
The entire collection of .xml files can be downloaded here: uscounties.zip (7.14MB)
The files needed to integrate with TNG's Google Maps can be downloaded here:
   TNG v6.0: counties_addon_6.zip
   TNG v7.0: counties_addon_7.zip

  This site powered by The Next Generation of Genealogy Sitebuilding ©, written by Darrin Lythgoe 2001-2008.

  Effortless Ancestry