[OGDev] A fix for the map links
Kake L Pugh
kake at earth.li
Mon Feb 26 20:00:26 GMT 2007
Earle points out that I forgot to attach the patches. Here they are.
Sorry about that!
Kake
-------------- next part --------------
--- OpenGuides-0.58/lib/OpenGuides.pm 2006-12-21 22:18:29.000000000 +0000
+++ OpenGuides.pm 2007-02-26 18:47:43.000000000 +0000
@@ -625,6 +625,7 @@
$tt_vars{zoom} = $q->param('zoom') || '';
$tt_vars{lat} = $q->param('lat') || '';
$tt_vars{long} = $q->param('long') || '';
+ $tt_vars{map_type} = $q->param('map_type') || '';
$tt_vars{centre_long} = $self->config->centre_long;
$tt_vars{centre_lat} = $self->config->centre_lat;
$tt_vars{default_gmaps_zoom} = $self->config->default_gmaps_zoom;
-------------- next part --------------
--- OpenGuides-0.58/templates/map_index.tt 2006-12-21 22:18:29.000000000 +0000
+++ map_index.tt 2007-02-26 18:44:06.000000000 +0000
@@ -1,4 +1,4 @@
-[% INCLUDE header.tt page_title = "Map of all nodes" %]
+[% 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>
@@ -29,6 +29,11 @@
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 %]
@@ -49,13 +54,23 @@
map.addOverlay(marker[% i %]);
[% END %]
[% END %]
- function map_recenter() {
+ function map_change() {
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;
+ 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_recenter );
+ GEvent.addListener(map, "moveend", map_change );
+ GEvent.addListener(map, "maptypechanged", map_change );
//]]>
</script>
[% ELSE %]
More information about the OpenGuides-Dev
mailing list