Add to Technorati Favorites Google Maps experiments
..................................
the blog@spencerwilliams.net

Google Maps experiments

January 5, 2008 07:12 by Spencer

I had played with Google maps a while back for a whole day about a year ago, before I got a GPS.  I lost interest because the only things I had that were geographically significant were pictures - and I didn't want to geotag ALL of them.  After getting a GPS, I played around with the track downloads and made a basic page to display a geocaching trip my wife and I took.

http://www.spencerwilliams.net/GeoCaching/GETest1.html

Pretty basic code, just a button to turn the KML overlay on and off, no dynamic centering of the map -

 <script type="text/javascript">

    var map;
    var geoXml;
    var toggleState = 1;

    var geoCallback = function()
     {
       geoXml.gotoDefaultViewport(map);
    }

    function initialize() {
      if (GBrowserIsCompatible()) {
        geoXml = new GGeoXml("
http://www.spencerwilliams.net/kml/kmltest3.xml", geoCallback);
        map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(30.30, -97.70), 11);
        map.addControl(new GLargeMapControl());
        var mapControl = new GMapTypeControl();
        map.addMapType(G_PHYSICAL_MAP);
        map.setMapType(G_HYBRID_MAP);
        map.addControl(mapControl);
        map.addOverlay(geoXml);
      }
    }

    function toggleMyKml() {
      if (toggleState == 1) {
        map.removeOverlay(geoXml);
        toggleState = 0;
      } else {
        map.addOverlay(geoXml);
        toggleState = 1;
      }
    }
 </script>
  </head>

  <body onload="initialize()">
    <div id="map_canvas" style="width: 1024px; height: 768px; float:left; border: 1px solid black;"></div>
    </div>
    <br clear="all"/>
    <br/>
    <input type="button" value="Toggle KML" onClick="toggleMyKml();"/>
  </body>
</html> 

 


Related posts

Comments are closed
 
Blog Information Profile for williasp