source: trunk/templates/map_index.tt @ 867

Last change on this file since 867 was 867, checked in by Dominic Hargreaves, 15 years ago

&/& -> ;

File size: 2.9 KB
Line 
1[% INCLUDE header.tt page_title = "Map of all nodes" %]
2[% INCLUDE banner.tt %]
3<div id="content">
4<a href="" id="permalink">Link to this page</a>
5
6<div id="maincontent">
7
8[% IF gmaps_api_key %]
9  <ul style="height:400px; overflow:auto;float:right; width:30%;">
10  [% i = 0 %]
11  [% FOREACH node = nodes %]
12    [% metadata = node.node_data.metadata %]
13    [% i = i + 1 %]
14    [% IF metadata.latitude.list.first AND metadata.longitude.list.first %]
15      [% NEXT IF metadata.latitude.list.first.match('m') %]
16      [% NEXT IF metadata.longitude.list.first.match('m') %]
17      <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>
18    [% END %]
19  [% END %]
20  </ul>
21
22  <table width="100%" height="100%">
23  <tr><td><div id="map" style=" width: 65%; height: 450px"></div></td></tr>
24  </table>
25
26  <script defer="defer" type="text/javascript">
27    //<![CDATA[
28      var map = new GMap(document.getElementById("map"));
29      map.addControl(new GLargeMapControl());
30      map.addControl(new GMapTypeControl());
31      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 %]);
32
33      [% i = 0 %]
34      [% FOREACH node = nodes %]
35        [% i = i + 1 %]
36        [% metadata = node.node_data.metadata %]
37        [% IF metadata.latitude.list.first AND metadata.longitude.list.first %]
38        [% NEXT IF metadata.latitude.list.first.match('m') %]
39        [% NEXT IF metadata.longitude.list.first.match('m') %]
40          var point[% i %] = new GPoint([% metadata.longitude.list.first %], [% metadata.latitude.list.first %]);
41          var marker[% i %] = new GMarker(point[% i %],baseIcon);
42          [% IF metadata.source %]
43            [% source_url = metadata.source.list.first.match('^(.*?)\?(?:\?|$)').first %]
44          [% END %]
45          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 %]";
46          GEvent.addListener(marker[% i %], "click", function() {
47            marker[% i %].openInfoWindowHtml(htmlString[% i %]);
48            });
49          map.addOverlay(marker[% i %]);
50        [% END %]
51      [% END %]
52      function map_recenter() {
53        var center = map.getCenterLatLng();
54        var link = document.getElementById('permalink');
55        var zoom = map.getZoomLevel();
56        link.href = "?action=index;format=map;long="+center.x+";lat="+center.y+";zoom="+zoom;
57      }
58      GEvent.addListener(map, "moveend", map_recenter );
59    //]]>
60  </script>
61[% ELSE %]
62  Sorry, this guide doesn't have Google Maps functionality enabled.
63[% END %]
64
65</div>
66</div>
67
68[% INCLUDE footer.tt %]
Note: See TracBrowser for help on using the repository browser.