Revision [14619]

This is an old revision of GoogleMap made by DarTar on 2006-06-16 08:49:24.


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 for details.
  6.  *
  7.  * @todo: params for height/width, location,. controls etc.
  8.  */
  10. <?php
  11. $key = abc  //the key you get from google
  12. ?>
  14. <script src="<?php echo $key ?>" type="text/javascript"></script>
  15. <div id="map" style="width: 300px; height: 300px"></div>
  16. <script type="text/javascript">
  17. //<![CDATA[
  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. }
  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.



      1. As an action:
        {{googlemap source="blablabla.xml"}}
        Actions are used to generate content within a page, so this might be the most natural way to implement this kind of functionality. The problem with this approach is that the XML data source should be created manually, as you suggest, and this is not an interesting option. Alternatively we could have data stored as plain text in another page (say MyPage) and use a specific '/xml' handler to parse this page and generate the data file to be used by the action, e.g.
        {{googlemap source="MyPage/xml"}}
      1. As a handler:
        A handler typically performs operations on a page as a whole. A /googlemaps handler could display a specific map depending on whether specific strings are present in the page body or, alternatively - if appended to a UserPage - display the location of the user (as stored in a dedicated field of the user table).
      1. As a formatter
        Maybe the most interesting way to implement Google Maps would be to use a specific markup, e.g.

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