Author: dom
Date: 2005-12-21 18:47:52 +0000 (Wed, 21 Dec 2005)
New Revision: 731
Added:
trunk/templates/map_index.tt
Modified:
trunk/preferences.cgi
trunk/t/13_cookies.t
Log:
Couple of things missing from previous commit.
Modified: trunk/preferences.cgi
===================================================================
--- trunk/preferences.cgi 2005-12-21 18:16:36 UTC (rev 730)
+++ trunk/preferences.cgi 2005-12-21 18:47:52 UTC (rev 731)
@@ -1,4 +1,4 @@
-#!/usr/local/bin/perl
+#!/usr/bin/perl
use warnings;
use strict;
Modified: trunk/t/13_cookies.t
===================================================================
--- trunk/t/13_cookies.t 2005-12-21 18:16:36 UTC (rev 730)
+++ trunk/t/13_cookies.t 2005-12-21 18:47:52 UTC (rev 731)
@@ -3,7 +3,7 @@
use OpenGuides::CGI;
use Time::Piece;
use Time::Seconds;
-use Test::More tests => 19;
+use Test::More tests => 20;
eval { OpenGuides::CGI->make_prefs_cookie; };
ok( $@, "->make_prefs_cookie dies if no config object supplied" );
@@ -27,6 +27,7 @@
default_edit_type => "tidying",
cookie_expires => "never",
track_recent_changes_views => 1,
+ display_google_maps => 1
);
isa_ok( $cookie, "CGI::Cookie", "->make_prefs_cookie returns a cookie" );
@@ -63,9 +64,10 @@
is( $prefs{default_edit_type}, "tidying", "...and default edit prefs" );
is( $prefs{cookie_expires}, "never", "...and requested cookie expiry" );
ok( $prefs{track_recent_changes_views}, "...and recent changes tracking" );
+is( $prefs{display_google_maps}, 1, "...and Google Maps display preference" );
# Check that cookie parsing fails nicely if no cookie set.
delete $ENV{HTTP_COOKIE};
%prefs = eval { OpenGuides::CGI->get_prefs_from_cookie( config => $config ); };
is( $@, "", "->get_prefs_from_cookie doesn't die if no cookie set" );
-is( keys %prefs, 9, "...and returns nine default values" );
+is( keys %prefs, 10, "...and returns ten default values" );
Added: trunk/templates/map_index.tt
===================================================================
--- trunk/templates/map_index.tt 2005-12-21 18:16:36 UTC (rev 730)
+++ trunk/templates/map_index.tt 2005-12-21 18:47:52 UTC (rev 731)
@@ -0,0 +1,61 @@
+[% INCLUDE header.tt page_title = "Map of all nodes" %]
+[% INCLUDE banner.tt %]
+<div id="content">
+<a href="" id="permalink">Link to this Page</a> | <a href="" onclick="showTowns(); return false;">Show Town Boundaries</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.latitude.list.first AND metadata.longitude.list.first %]
+ <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 %]);
+
+ [% i = 0 %]
+ [% FOREACH node = nodes %]
+ [% i = i + 1 %]
+ [% metadata = node.node_data.metadata %]
+ [% IF metadata.latitude.list.first AND metadata.longitude.list.first %]
+ var point[% i %] = new GPoint([% metadata.longitude.list.first %], [% metadata.latitude.list.first %]);
+ var marker[% i %] = new GMarker(point[% i %],baseIcon);
+ var htmlString[% i %] = "<a href=\"?[% node.param %]\">[% node.name %]</a> <a style='text-decoration:none;' href=\"?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_recenter() {
+ var center = map.getCenterLatLng();
+ var link = document.getElementById('permalink');
+ var zoom = map.getZoomLevel();
+ link.href = "?action=index;format=map&long="+center.x+"&lat="+center.y+"&zoom="+zoom;
+ }
+ GEvent.addListener(map, "moveend", map_recenter );
+ //]]>
+ </script>
+[% ELSE %]
+ Sorry, this guide doesn't have Google Maps functionality enabled.
+[% END %]
+
+</div>
+</div>
+
+[% INCLUDE footer.tt %]