Maps

If your web content has geographic context, meaning, it is located at a specific field office, library, business, project site, etc., then you can place a reference to that web content on a map. This will enable people to find services and information by querying a map from where they are instead of the typical text-based search.

Introduction

KML is becoming for maps on the Web what RSS has become for blogs and newsfeeds. Both are based on open XML standards which enable information to be syndicated and published on any website or tool that can subscribe to it. KML was adopted as an industry open standard by the Open Geospatial Consortium (OGC) and is becoming incorporated into all the geospatial tools and map service websites. (See: OGC Approves KML as an Open Standard )

Today, many common map tools import KML including: Google Maps, Microsoft Live Maps, Google Earth, Microsoft Live Earth, Arc GIS Explorer, and many more.

KML is designed to be very scalable from both a functionality and volume standpoint. Utilizing a “networklink” within a KML file one can essentially publish a map interface service on top of their database. Then with a few lines of code this same map/database service could become incorporated into another website providing access to an extensive source of map information. The opportunities for reuse and repurposing of map related data in mashups utilizing the KML format are almost unlimited!

The following is a step-by-step description of how to place your information on a map. This “how to” process only addresses placing “places” or placemarks into a KML format and then publishing KML files via various map tools and websites. There are many other types of map information that could potentially be published, but that is beyond the scope of this particular “how to” description.

Eventually KML publishing could become a “push button” process of a “directory” or “events” component of a content management system (much like the way RSS feed publishing and podcasting have become today).

Option A: Publish Your Map Info as a KML File

This option can be utilized when the number of placemarks in your map data is around 700 or less.

The easiest way to accomplish this is to utilize a free service available on the Web that will:

  1. “Geocode” your data for you, meaning that: based upon the address locations of the places, it will assign the appropriate geographic coordinates of latitude and longitude to your data so it can be displayed on a map.
  2. “KML” tag your data for you (including the geocodes it looked up for you). You can find this free service at www.batchgeo.com.

There is an easy explanation of the process and format (tabbed spreadsheet). The only thing left that you must do after using this service, is modify the top portion of the KML to point to the image file that you want to use for your placemarks on the map.

More Than 200 Placemarks?

If your data in your KML file exceeds 200 placemarks, you have some more work to do. Web Maps (like Google Maps) do not handle a file of over 200 placemarks accurately. So if you have 700 placemarks, you are going to have to divide the KML data up into at least 4 different files. Then you will use a single “KML Networklink” file to bring them all together into one map URL interface (so your map application has only one URL to call to bring in the map data.)

Option B: Publish Your Map Info Utilizing KML Regions

KML Regions are typically generated out of a sophisticated Geographic Information System (GIS). Consequently most explanations of this capability are in the context of more complicated map information than is being described within this webpage. If you were to utilize “KML regions” it would be to deal with a number of records that starts to exceed 700.

Utilizing a KML regions technique you could partition your data into multiple files that the map application could use to control how many records get loaded based upon where the user is moving on the map. Consequently, if you properly “regionalize” your data, the amount of map data you have can be much larger, even up to 10,000 or more. But manually managing that large of an amount of data in files would probably be impractical. So managing “regionalized” data in files probably would work for around 500 to 2000 placemarks – – as long as new placemarks were not added often.

Because of the technical complexities of implementing this method without a GIS tool, it is not recommended unless you have already gained some experience in implementing kml within map applications.

Option C: Publish Your Map Info as a KML Application

This option would typically be used when the placemark data is stored in a database, and the number of placemarks for the map exceeds 700 or so. Although this method is more difficult to initially build, once it is built, it is much easier to maintain and scale up.

The requirements for implementing this method are:

  1. The data must be located in a database
  2. The geographic coordinates for the data must be stored with the data in the database
  3. The database application must be able to query the database via an index on the geographic coordinates
  4. The database application must output the data in a KML format
  5. The database application must be called via a KML Networklink file

Stay “tuned” as we hope in the future to be able to publish some “pre-built” scripts that could be leveraged, with some modification, to enable this technique for your map data.

Integrate KML Into Websites

If you look at the source code for this webpage, you will see the source javascript and HTML code to enable you to implement a similar map on your website.

You must have a Google Maps API Key for your website’s domain. But don’t worry, it is free.

Go to: Sign up for Google Maps where you can get it by putting in your domain name and agreeing to the terms and conditions. No Google account is needed.

The Google Maps Key is a long string located in the javascript “script src=” call (see next):

script src=”http://maps.google.com/maps?file=api&v=2.x&key=ABQIAAAAVnV-znR9mz4M8R3FtGWGwBTN1invGuwWs6v0GEf1CZ8nHxukCxQmTcgjCrbrhvuMU1zvvdx3FrlLkw

The following code shown in the image below is a portion of the javascript for this map webpage.

The “var layers” portion designates what KML files to bring to the map so people can “check” them to put them on the map. You must fill this in for your data, for example:

“cc”:

{“url” : “http://eServices.CA.gov.googlepages.com/CC.kml”,

“name”: “Community Colleges”,

“icon”: “http://eservices.ca.gov.googlepages.com/casetta_yellow.png”},

The code to position the map is highlighted in blue. You must fill in the coordinates of

latitude and longitude (38.58000, -121.40000) and the altitude view on your map, which in this case

it is at “8” which is very high allowing you to see from the Bay Area all the way to Sacramento.

The higher the number (up to “15”) will bring the view in closer.

map

Important: the altitude view must also be set in the following code within the javascript “function showAddress(address)” that is executed whenever the user clicks on “New Map Location.”

Currently it looks like this: “map.setCenter(point, 8)”

In this case it is set at “8”, but it must be changed to match the value you place in the “map.setCenter” code highlighted above.

Resources

0 Comments

Submit a Comment