The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
[% INCLUDE header.tt page_title = criterion.name || "Map of all nodes" %]
[% INCLUDE banner.tt %]
<div id="content">
<a href="" id="permalink">Link to this page</a>

<div id="maincontent">

[% IF gmaps_api_key %]
  <ul style="height:400px; overflow:auto;float:right; width:30%;">
  [% i = 0 %]
  [% FOREACH node = nodes %]
    [% metadata = node.node_data.metadata %]
    [% i = i + 1 %]
    [% IF metadata.wgs84_lat.list.first AND metadata.wgs84_long.list.first %]
      [% NEXT IF metadata.wgs84_lat.list.first.match('m') %]
      [% NEXT IF metadata.wgs84_long.list.first.match('m') %]
      <li><a href='#' onclick="marker[% i %].openInfoWindowHtml(htmlString[% i %]); return false;">[% node.name %]</a>[% IF metadata.city.list.first %], [% metadata.city.list.first %][% END %]</li>
    [% END %]
  [% END %]
  </ul>

  <table width="100%" height="100%">
  <tr><td><div id="map" style=" width: 65%; height: 450px"></div></td></tr>
  </table>

  <script defer="defer" type="text/javascript">
    //<![CDATA[
      var map = new GMap(document.getElementById("map"));
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.centerAndZoom(new GPoint([% IF long %][% long %][% ELSE %][% centre_long %][% END %],[% IF lat %][% lat %][% ELSE %][% centre_lat %][% END %]), [% IF zoom %][% zoom %][% ELSE %][% default_gmaps_zoom %][% END %]);
      [% IF map_type == "satellite" %]
        map.setMapType( G_SATELLITE_TYPE );
      [% ELSIF map_type == "hybrid" %]
        map.setMapType( G_HYBRID_TYPE );
      [% END %]

      [% i = 0 %]
      [% FOREACH node = nodes %]
        [% i = i + 1 %]
        [% metadata = node.node_data.metadata %]
        [% IF metadata.wgs84_lat.list.first AND metadata.wgs84_long.list.first %]
        [% NEXT IF metadata.wgs84_lat.list.first.match('m') %]
        [% NEXT IF metadata.wgs84_long.list.first.match('m') %]
          var point[% i %] = new GPoint([% metadata.wgs84_long.list.first %], [% metadata.wgs84_lat.list.first %]); 
          var marker[% i %] = new GMarker(point[% i %],baseIcon);
          [% IF metadata.source %]
            [% source_url = metadata.source.list.first.match('^(.*?)\?(?:\?|$)').first %]
          [% END %]
          var htmlString[% i %] = "<a href=\"?[% node.param %]\">[% node.name %]</a>&nbsp;<a style='text-decoration:none;' href=\"[% source_url %]?id=[% node.param %];action=edit\">(edit)</a><br />[% metadata.address.list.first %]<br />[% metadata.city.list.first %]";
          GEvent.addListener(marker[% i %], "click", function() { 
            marker[% i %].openInfoWindowHtml(htmlString[% i %]); 
            }); 
          map.addOverlay(marker[% i %]); 
        [% END %]
      [% END %]
      function map_change() {
        var center = map.getCenterLatLng();
        var link = document.getElementById('permalink');
        var zoom = map.getZoomLevel();
        var type = map.getCurrentMapType();
        var map_type;
        if ( type == G_SATELLITE_TYPE ) {
          map_type = "satellite";
        } else if ( type == G_HYBRID_TYPE ) {
          map_type = "hybrid";
        } else {
          map_type = "";
      }
      link.href = "?action=index;format=map;long="+center.x+";lat="+center.y+";zoom="+zoom+";map_type="+map_type[% IF criterion.type %][% IF criterion.value %]+";index_type="+encodeURIComponent("[% criterion.type %]")+";index_value="+encodeURIComponent("[% criterion.value %]")[% END %][% END %];
      }
      GEvent.addListener(map, "moveend", map_change );
      GEvent.addListener(map, "maptypechanged", map_change );
    //]]>
  </script>
[% ELSE %]
  Sorry, this guide doesn't have Google Maps functionality enabled.
[% END %]

</div>
</div>

[% INCLUDE footer.tt %]