{"id":112,"date":"2010-01-03T13:59:08","date_gmt":"2010-01-03T17:59:08","guid":{"rendered":"http:\/\/www.carolinamantis.com\/wordpress\/?p=112"},"modified":"2012-10-31T14:07:27","modified_gmt":"2012-10-31T18:07:27","slug":"using-google-mymaps-as-live-kml-data-sources","status":"publish","type":"post","link":"http:\/\/www.carolinamantis.com\/wordpress\/?p=112","title":{"rendered":"Using Google MyMaps as Live KML Data Sources"},"content":{"rendered":"<div class=\"wp_plus_one_button\" style=\"margin: 0 8px 8px 0; float:left; \"><g:plusone href=\"http:\/\/www.carolinamantis.com\/wordpress\/?p=112\" callback=\"wp_plus_one_handler\"><\/g:plusone><\/div><p>I felt very clever when I discovered how to get to the actual KML exported as part of the &#8220;View in Google Earth&#8221; feature of Google&#8217;s MyMaps area of <a title=\"Google Maps\" href=\"http:\/\/maps.google.com\">Google Maps<\/a>.\u00a0 I still don&#8217;t know why I didn&#8217;t make the leap sooner from downloading the data to using it live in an application.\u00a0 Although I figured it out on my own, I would have made the &#8220;discovery&#8221; sooner if I just had read <a title=\"Mike Williams' Google Maps API Tutorial\" href=\"http:\/\/econym.org.uk\/gmap\/\">Mike Williams Google Maps API Tutorial<\/a> with a <a href=\"http:\/\/econym.org.uk\/gmap\/egeoxml.htm\">closer eye to detail<\/a>.\u00a0 My one excuse is that I didn&#8217;t originally use alternatives to Google&#8217;s own <a title=\"Google Maps API: GGeoXml\" href=\"http:\/\/code.google.com\/apis\/maps\/documentation\/reference.html#GGeoXml\">GGeoXML<\/a> class.\u00a0 Now that I&#8217;m collaborating with multiple map maintainers, I don&#8217;t want to go through the whole download\/massage\/publish cycle.\u00a0 Instead I want to use the excellent editing and collaboration facilities of the MyMaps interface to allow others to keep things updated properly.<\/p>\n<p>In the spirit of sharing, I want to walk you through the process of going from MyMaps to your own hosted map using that data as an overlay.<\/p>\n<ol>\n<li><a title=\"Google Account Signup\" href=\"https:\/\/www.google.com\/accounts\/NewAccount\">Get a Google Account<\/a><\/li>\n<li>Sign in and <a title=\"Google Maps Home Page\" href=\"http:\/\/maps.google.com\">Visit Google Maps<\/a><\/li>\n<li>Create your first My Map.\u00a0 Click the My Maps link in the left side bar, then click Create New Map.<\/li>\n<li>Set the center point and map display type using the normal maps interface.<\/li>\n<li>Edit the map by using the Edit button.<\/li>\n<li>Save the map using the Save button.<\/li>\n<\/ol>\n<p>Note that you can add polylines and markers to your map, as well as edit the marker information as plain text, rich text, or HTML.\u00a0 You can pick icons for your markers or add your own.\u00a0 Note that adding your own doesn&#8217;t add to a data store, but uses a URL reference.\u00a0 If you don&#8217;t maintain or control the server hosting the image, you won&#8217;t be able to guarantee that your custom marker will always be available.<\/p>\n<p>When you&#8217;re happy with your map, use the View in Google Earth link above the map display itself (between RSS and Print).\u00a0 Instead of letting Google Earth load the file, save it to your computer.<\/p>\n<p>To help with my examples, I created a <a title=\"Demo Map Showing East Carolina University\" href=\"http:\/\/maps.google.com\/maps\/ms?ie=UTF8&amp;hl=en&amp;msa=0&amp;msid=113918317131300723802.00047c45b431d9dc64cb7&amp;ll=35.605812,-77.36598&amp;spn=0.037614,0.090895&amp;z=14\">Demo Map Showing East Carolina University<\/a> in my public Google account.\u00a0 The link in my blog post was created by using the handy Link link within the interface.<\/p>\n<p>You&#8217;ll note that the file size of the kml file is very small, which if you&#8217;ve created many markers with detailed information will seem confusing.\u00a0 This XML doesn&#8217;t contain your data, but contains a URL to your data.\u00a0 For instance, here is the contents of the KML file exported for my demo map:<\/p>\n<pre name=\"code\" class=\"xml\"><!--?xml version=\"1.0\" encoding=\"UTF-8\"?-->\r\n\r\n  Demo Map Showing East Carolina University\r\n  <![CDATA[This is a simple one-marker map showing the center of East Carolina University's Main Campus.]]>\r\n\r\n    Demo Map Showing East Carolina University\r\n\r\n      http:\/\/maps.google.com\/maps\/ms?ie=UTF8&amp;hl=en&amp;oe=UTF8&amp;msa=0&amp;msid=113918317131300723802.00047c45b431d9dc64cb7&amp;output=kml<\/pre>\n<p>The important feature of this file is the href element inside that link element. That&#8217;s the URL we want to our actual KML data. If we with to use it with GGeoXML, we can just replace the entities with their single character equivalents and construct the layer:<\/p>\n<pre name=\"code\" class=\"javascript\">geoXml = new GGeoXml(\"http:\/\/maps.google.com\/maps\/ms?ie=UTF8&amp;hl=en&amp;oe=UTF8&amp;msa=0&amp;msid=113918317131300723802.00047c45b431d9dc64cb7&amp;output=kml\");\r\nmap.addOverlay(geoXml);<\/pre>\n<p>That&#8217;s all there is to it. Now if you or any collaborator edits the map, the next time it&#8217;s reloaded the GGeoXML class will pick up the latest version. Next time I&#8217;ll discuss using the much more advanced Geoxml class. It requires one more bit of work because it cannot load data from URLs that are not within the same domain.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"wp_plus_one_button\" style=\"margin: 0 8px 8px 0; float:left; \"><g:plusone href=\"http:\/\/www.carolinamantis.com\/wordpress\/?p=112\" callback=\"wp_plus_one_handler\"><\/g:plusone><\/div><p>I felt very clever when I discovered how to get to the actual KML exported as part of the &#8220;View in Google Earth&#8221; feature of Google&#8217;s MyMaps area of Google Maps.\u00a0 I still don&#8217;t know why I didn&#8217;t make the leap sooner from downloading the data to using it live in an application.\u00a0 Although I [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1288,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"_links":{"self":[{"href":"http:\/\/www.carolinamantis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/112"}],"collection":[{"href":"http:\/\/www.carolinamantis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.carolinamantis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.carolinamantis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.carolinamantis.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=112"}],"version-history":[{"count":17,"href":"http:\/\/www.carolinamantis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/112\/revisions"}],"predecessor-version":[{"id":1293,"href":"http:\/\/www.carolinamantis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/112\/revisions\/1293"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.carolinamantis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/media\/1288"}],"wp:attachment":[{"href":"http:\/\/www.carolinamantis.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.carolinamantis.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=112"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.carolinamantis.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}