aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2011-05-25 14:28:40 +0100
committerMatthew Somerville <matthew@mysociety.org>2011-05-25 14:28:40 +0100
commitfe35ddba0fab0ebc413300dff0f1f323aec40e9a (patch)
tree00e7253bf8f6fa6e399a857450b31fe4b3d1bf12
parent34296c409fe2ab9f02e5aeb14100570a8fb68dea (diff)
Make tile URL a parameter so it can be different, bring OSM's StreetView under the same code.
-rw-r--r--perllib/FixMyStreet/Map/OSM.pm11
-rw-r--r--perllib/FixMyStreet/Map/OSM/CycleMap.pm4
-rw-r--r--perllib/FixMyStreet/Map/OSM/StreetView.pm40
-rw-r--r--templates/web/default/maps/osm.html10
4 files changed, 28 insertions, 37 deletions
diff --git a/perllib/FixMyStreet/Map/OSM.pm b/perllib/FixMyStreet/Map/OSM.pm
index 9ccbac017..971f88fd7 100644
--- a/perllib/FixMyStreet/Map/OSM.pm
+++ b/perllib/FixMyStreet/Map/OSM.pm
@@ -10,7 +10,6 @@ package FixMyStreet::Map::OSM;
use strict;
use Math::Trig;
-use mySociety::Web qw(ent NewURL);
use Utils;
sub header_js {
@@ -25,6 +24,14 @@ sub map_type {
return 'OpenLayers.Layer.OSM.Mapnik';
}
+sub base_tile_url {
+ return 'tile.openstreetmap.org';
+}
+
+sub copyright {
+ return _('Map &copy; <a id="osm_link" href="http://www.openstreetmap.org/">OpenStreetMap</a> and contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>');
+}
+
# display_map C PARAMS
# PARAMS include:
# latitude, longitude for the centre point of the map
@@ -72,6 +79,8 @@ sub display_map {
latitude => $params{latitude},
longitude => $params{longitude},
map_type => $self->map_type(),
+ tile_url => $self->base_tile_url(),
+ copyright => $self->copyright(),
x_tile => $x_tile,
y_tile => $y_tile,
zoom => $zoom,
diff --git a/perllib/FixMyStreet/Map/OSM/CycleMap.pm b/perllib/FixMyStreet/Map/OSM/CycleMap.pm
index 06b07ae20..71b86de8f 100644
--- a/perllib/FixMyStreet/Map/OSM/CycleMap.pm
+++ b/perllib/FixMyStreet/Map/OSM/CycleMap.pm
@@ -15,4 +15,8 @@ sub map_type {
return 'OpenLayers.Layer.OSM.CycleMap';
}
+sub base_tile_url {
+ return 'tile.opencyclemap.org/cycle';
+}
+
1;
diff --git a/perllib/FixMyStreet/Map/OSM/StreetView.pm b/perllib/FixMyStreet/Map/OSM/StreetView.pm
index 9512e2013..ba7134c1e 100644
--- a/perllib/FixMyStreet/Map/OSM/StreetView.pm
+++ b/perllib/FixMyStreet/Map/OSM/StreetView.pm
@@ -7,9 +7,9 @@
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
package FixMyStreet::Map::OSM::StreetView;
+use base 'FixMyStreet::Map::OSM';
use strict;
-use mySociety::Web qw(ent);
sub header_js {
return '
@@ -19,38 +19,16 @@ sub header_js {
';
}
-# display_map C PARAMS
-# PARAMS include:
-# latitude, longitude for the centre point of the map
-# TYPE is 1 if the map is clickable, 0 otherwise.
-# PINS is array of pins to show, location and colour
-sub display_map {
- my ($self, $c, %params) = @_;
- $params{pre} ||= '';
-
- my @pins;
- foreach my $pin (@{$params{pins}}) {
- $pin->[3] ||= '';
- push @pins, "[ $pin->[0], $pin->[1], '$pin->[2]', '$pin->[3]' ]";
- }
- my $pins_js = join(",\n", @pins);
+sub map_type {
+ return '""';
+}
- my $out = '';
- my $copyright = _('Map contains Ordnance Survey data &copy; Crown copyright and database right 2010.');
- $out .= <<EOF;
-<script type="text/javascript">
-var fixmystreet = {
- 'latitude': $params{latitude},
- 'longitude': $params{longitude},
- 'pins': [ $pins_js ]
+sub base_tile_url {
+ return 'os.openstreetmap.org/sv';
}
-</script>
-<div id="map_box">
- $params{pre}
- <div id="map"></div>
- <p id="copyright">$copyright</p>
-EOF
- return $out;
+
+sub copyright {
+ return _('Map contains Ordnance Survey data &copy; Crown copyright and database right 2010.');
}
1;
diff --git a/templates/web/default/maps/osm.html b/templates/web/default/maps/osm.html
index 4c1c23166..bdc6b8cb3 100644
--- a/templates/web/default/maps/osm.html
+++ b/templates/web/default/maps/osm.html
@@ -23,25 +23,25 @@ var fixmystreet = {
<div id="drag"><[% map.img_type %]
alt="NW map tile" id="t2.2"
name="tile_[% map.x_tile - 1 %].[% map.y_tile - 1 %]"
- src="http://a.tile.openstreetmap.org/[% map.zoom_act %]/[% map.x_tile - 1 %]/[% map.y_tile - 1 %].png"
+ src="http://a.[% map.tile_url %]/[% map.zoom_act %]/[% map.x_tile - 1 %]/[% map.y_tile - 1 %].png"
style="top:0; left:0;"><[% map.img_type %]
alt="NE map tile" id="t2.3"
name="tile_[% map.x_tile %].[% map.y_tile - 1 %]"
- src="http://b.tile.openstreetmap.org/[% map.zoom_act %]/[% map.x_tile %]/[% map.y_tile - 1 %].png"
+ src="http://b.[% map.tile_url %]/[% map.zoom_act %]/[% map.x_tile %]/[% map.y_tile - 1 %].png"
style="top:0px; left:256px;"><br><[% map.img_type %]
alt="SW map tile" id="t3.2"
name="tile_[% map.x_tile - 1 %].[% map.y_tile %]"
- src="http://c.tile.openstreetmap.org/[% map.zoom_act %]/[% map.x_tile - 1 %]/[% map.y_tile %].png"
+ src="http://c.[% map.tile_url %]/[% map.zoom_act %]/[% map.x_tile - 1 %]/[% map.y_tile %].png"
style="top:256px; left:0;"><[% map.img_type %]
alt="SE map tile" id="t3.3"
name="tile_[% map.x_tile %].[% map.y_tile %]"
- src="http://tile.openstreetmap.org/[% map.zoom_act %]/[% map.x_tile %]/[% map.y_tile %].png"
+ src="http://[% map.tile_url %]/[% map.zoom_act %]/[% map.x_tile %]/[% map.y_tile %].png"
style="top:256px; left:256px;"></div>
<div id="pins">[% FOR pin IN map.pins %][% INCLUDE pin %][% END %]</div>
[% INCLUDE compass %]
</noscript></div>
<p id="copyright">
- [% loc('Map &copy; <a id="osm_link" href="http://www.openstreetmap.org/">OpenStreetMap</a> and contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>') %]
+ [% map.copyright %]
</p>