WebTools branding banner, with hammer and wrench tools in background

Right Column

Put it on the Map!

If your web content about a service or project has a 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 the 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.

Demo of Google Maps


Type city & state or full address:

Use the following KML files to view this same map information in: Google Earth, Microsoft Virtual Earth, etc.

KML file Community Colleges      KML file CA State Universities      KML file Universities of CA      KML file Independent Colleges

Introduction

KML is becoming for maps on the Web what RSS has become for blogs and newsfeeds. Both are based on the very open XML standard which enables information to be syndicated and published on any website or tool that can subscribe to it. KML was recently adopted as an industry open standard by the Open Geospatial Consortium (OGC) and is quickly becoming incorporated into all the geospatial tools and map service websites. (See: OGC Approves KML as an Open Standard ) Today already many common map tools will import KML including: Google Maps, Microsoft Live Maps, Google Earth, Microsoft Live Earth, Arc GIS Explorer, and many, 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. If you look at the simple demo shown above, the information available to the map actually comes from multiple organizations. 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 the 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.)

For an introduction into how a KML file is formatted for publishing placemarks on a map, see: Format of a KML file - explained.

For a good listing of information and tools related to creating and utilizing KML and Google Earth see: "Google Earth Resources for Educators"

Periodically the eServices Office will hold free Maps Publishing Workshops for agency webmasters to help them publish their geographic related information utilizing the open KML format.



Option A: Publish Your Map Info as a KML File(s)

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.batchgeocode.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.

The eServices Office periodically holds free workshops for agency webmasters to help them publish their geographic related information into the open KML format. Published here is the Maps Publishing Workshop process they work through utilizing the www.batchgeocode.com website service.

More than 200 Placemarks?

Now if your data in your KML file exceeds 200 placemarks, you do 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.)

In the Google Maps demo above, the "Libraries With WiFi Access" map data is actually divided up into 4 files. But the map only calls one KML Networklink file. You can download and view that network link file at: KML file All Libraries With WiFi Access

Important to Note!

The demo map above actually has TOO MUCH data available to it. (Remember, only 200 placemarks can be viewed at any one time on the map.) If you leave the DMV data on it and then add a bunch of other data (UCs, CSUs, Community Colleges, etc) only a portion of the placemarks will show up! At the "map view" of the demo above (where you can see both the Bay Area and the Sacramento Area) too many placemarks will need to become visible. You must either not offer so many types of data for the map, or you must make the view of the map to be "closer in" to only cover (for example) the Sacramento Area.



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. For a full explanation of KML Regions, see Google KML Regions Tutorial

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.

First things: you must have a Google Maps API Key for your website's domain. But don't worry, it is free. Just 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, the data for Community Colleges is accomplished with the following code:

"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.

Key Javascript Code in a Google Maps Webpage

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.