Revision [9704]

This is an old revision of GoogleMap made by NilsLindenberg on 2005-06-30 11:00:14.

 

Google Map


The Google Maps API lets developers embed Google Maps in their own web pages with JavaScript. You can add overlays to the map (including markers and polylines) and display shadowed "info windows" just like Google Maps. (quoted from Google maps API homepage).

Based on PivWans idea to use this service to build a UserMap, here is the first code for a googlemap action.

add the following as actions/googlemap.php

  1. /**
  2.  * prints a map from Googles Map-service on a page.
  3.  *
  4.  * Note that you have to register your (sub)domain with google to get a key to use the map.
  5.  * See http://www.google.com/apis/maps/signup.html for details.
  6.  *
  7.  * @todo: params for height/width, location,. controlls etc.
  8.  */
  9.  
  10. <?php
  11. $key = abc  //the key you get from google
  12. ?>
  13.  
  14. <script src="http://maps.google.com/maps?file=api&v=1&key= <?php echo $key ?>" type="text/javascript"></script>
  15. <div id="map" style="width: 300px; height: 300px"></div>
  16. <script type="text/javascript">
  17. //<![CDATA[
  18.  
  19. if (GBrowserIsCompatible()) {
  20.    var map = new GMap(document.getElementById("map"));
  21.    map.addControl(new GSmallMapControl());
  22.    map.addControl(new GMapTypeControl());
  23.    map.centerAndZoom(new GPoint(-122.141944, 37.441944), 4);
  24. }
  25.  
  26. //]]>
  27. </script>


This will print out a map with 300 x 300 pixel and the controls to change between map/satellite-picture and To move/zoom-in zoom-out. The map is centered to Paolo Alto.

Todo

There are 12 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki