A KML Sitemap
This post assumes basic understand of website structures and XML documents.
After finishing my adventure map (map.jacobemerick.com) a few weeks ago, I wanted to share the KML information online for people using Google Earth or Google Maps. A KML document is merely an XML document with special tags and data that is related to mapping - it includes latitudes, longitudes, and descriptions of geographical points. My adventure map parses KML documents to display the routes, photos, and points viewable on the map. However, in order to offer these KMLs in a way that search robots could view them, I had to do some modifications.
The first step was making sure that my KML documents were being read as KMLs. All of them are generated from a single PHP script, called processor.php, and I wanted to give them a content-type so that programs, including search robots, understood that it was a KML document. This was easy to add in my PHP document.
echo header('Content-type:Application/vnd.google-earth.kml+xml');
Since I have a large number of KML documents being generated by my script, I added this line in front of the document types that I wanted to be indexed and understood by programs. Even though the script still runs as a php document, the output will be interpreted as a KML document. If you have normal KMLs on your site, this step is not necessary.
The next step is to create your sitemap. This is merely an XML document that contains all of your web page urls. Normally, it would look like this...
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://map.jacobemerick.com/</loc>
<lastmod>2009-07-16</lastmod>
<priority>1.0</priority>
<changefreq>monthly</changefreq>
</url>
</urlset>
Each page has its own url, with a loc, lastmod, priority, and changefreq. Some of these are optional, but I'd recommend including at these three. For more information about these fields and values, just visit the Sitemaps site.
To add KMLs to this for programs to find, you first have to add a new schema in the opening tag. After this, you just tag the url as a KML document, and you're set. So, if I add a KML to the above sitemap, it would look like this...
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:geo="http://www.google.com/geo/schemas/sitemap/1.0">
<url>
<loc>https://map.jacobemerick.com/</loc>
<lastmod>2009-07-16</lastmod>
<priority>1.0</priority>
<changefreq>monthly</changefreq>
</url>
<url>
<loc>https://map.jacobemerick.com/?hike=Yellow+Dog+Falls</loc>
<lastmod>2009-07-16</lastmod>
<priority>0.2</priority>
<changefreq>never</changefreq>
<geo:geo>
<geo:format>kml</geo:format>
</geo:geo>
</url>
Now my map website has a low priority KML that shows the Yellow Dog Falls. That's all there is to it!
Comments (0)