Wednesday, June 24, 2009

Google mapplet basics

From this page here.

A mapplet is an XML file on your own webserver, which overlays stuff on the standard Google maps page. You run the mapplet in your webbrowser as follows:

http://maps.google.com/ig/add?synd=mpl&pid=mpl&moduleurl=...

For example, here is mine.

Here is the code for my mapplet:

<?xml version="1.0" encoding="UTF-8"?>
<Module>
  <ModulePrefs title="Bum bum bum" 
               description="Says bum a lot"
               author="Mark McConville"
               author_email="markmcco@gmail.com"
               height="150">
    <!-- load the Google mapplets API -->
    <Require feature="sharedmap"/>    
  </ModulePrefs>
  <Content type="html"><![CDATA[
    <!-- Add a title to the left-hand info pane -->
    <h2>Bum bum bum!</h2>
    <!-- Manipulate the map pane -->
    <script>
      <!-- create a new map -->
      var map = new GMap2();
      <!-- centre the map in middle of Mediterranean and zoom out to level 2 -->
      var point = new GLatLng(37.71859,6.679688);
      map.setCenter(point,2);
      <!-- add a marker/pin to the point -->
      var marker = new GMarker(point);
      map.addOverlay(marker);
      <!-- add an info bubble to the marker -->
      marker.openInfoWindowHtml("Bum bum bum!");
    </script>
    ]]>
  </Content>
</Module>

No comments:

Post a Comment