source: trunk/templates/map_index.tt @ 955

Last change on this file since 955 was 955, checked in by kake, 15 years ago

Fix "Link to this page" on index maps to remember the map type and the thing it's indexing (ticket #190).

File size: 3.6 KB
Line 
1[% INCLUDE header.tt page_title = criterion.name || "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      [% IF map_type == "satellite" %]
33        map.setMapType( G_SATELLITE_TYPE );
34      [% ELSIF map_type == "hybrid" %]
35        map.setMapType( G_HYBRID_TYPE );
36      [% END %]
37
38      [% i = 0 %]
39      [% FOREACH node = nodes %]
40        [% i = i + 1 %]
41        [% metadata = node.node_data.metadata %]
42        [% IF metadata.latitude.list.first AND metadata.longitude.list.first %]
43        [% NEXT IF metadata.latitude.list.first.match('m') %]
44        [% NEXT IF metadata.longitude.list.first.match('m') %]
45          var point[% i %] = new GPoint([% metadata.wgs84_long.list.first %], [% metadata.wgs84_lat.list.first %]);
46          var marker[% i %] = new GMarker(point[% i %],baseIcon);
47          [% IF metadata.source %]
48            [% source_url = metadata.source.list.first.match('^(.*?)\?(?:\?|$)').first %]
49          [% END %]
50          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 %]";
51          GEvent.addListener(marker[% i %], "click", function() {
52            marker[% i %].openInfoWindowHtml(htmlString[% i %]);
53            });
54          map.addOverlay(marker[% i %]);
55        [% END %]
56      [% END %]
57      function map_change() {
58        var center = map.getCenterLatLng();
59        var link = document.getElementById('permalink');
60        var zoom = map.getZoomLevel();
61        var type = map.getCurrentMapType();
62        var map_type;
63        if ( type == G_SATELLITE_TYPE ) {
64          map_type = "satellite";
65        } else if ( type == G_HYBRID_TYPE ) {
66          map_type = "hybrid";
67        } else {
68          map_type = "";
69      }
70      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 %];
71      }
72      GEvent.addListener(map, "moveend", map_change );
73      GEvent.addListener(map, "maptypechanged", map_change );
74    //]]>
75  </script>
76[% ELSE %]
77  Sorry, this guide doesn't have Google Maps functionality enabled.
78[% END %]
79
80</div>
81</div>
82
83[% INCLUDE footer.tt %]
Note: See TracBrowser for help on using the repository browser.