diff options
Diffstat (limited to 'perllib/FixMyStreet/Map')
-rw-r--r-- | perllib/FixMyStreet/Map/OSM.pm | 25 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/OSM/CycleMap.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/OSM/StreetView.pm | 40 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Tilma/Original.pm | 23 |
4 files changed, 29 insertions, 63 deletions
diff --git a/perllib/FixMyStreet/Map/OSM.pm b/perllib/FixMyStreet/Map/OSM.pm index 9ccbac017..aeece3960 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 © <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 @@ -45,18 +52,8 @@ sub display_map { my $zoom_act = 14 + $zoom; my ($x_tile, $y_tile) = latlon_to_tile_with_adjust($params{latitude}, $params{longitude}, $zoom_act); - my @pins; foreach my $pin (@{$params{pins}}) { - my ($px, $py) = latlon_to_px($pin->[0], $pin->[1], $x_tile, $y_tile, $zoom_act); - push @pins, { - lat => $pin->[0], - lon => $pin->[1], - px => $px, - py => $py, - col => $pin->[2], - id => $pin->[3], - title => $pin->[4], - }; + ($pin->{px}, $pin->{py}) = latlon_to_px($pin->{latitude}, $pin->{longitude}, $x_tile, $y_tile, $zoom_act); } my $compass = { @@ -72,11 +69,13 @@ 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, zoom_act => $zoom_act, - pins => \@pins, + pins => $params{pins}, compass => $compass, }; } 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 © 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 © Crown copyright and database right 2010.'); } 1; diff --git a/perllib/FixMyStreet/Map/Tilma/Original.pm b/perllib/FixMyStreet/Map/Tilma/Original.pm index 7ba0afab5..c7ff5a52f 100644 --- a/perllib/FixMyStreet/Map/Tilma/Original.pm +++ b/perllib/FixMyStreet/Map/Tilma/Original.pm @@ -49,14 +49,6 @@ sub display_map { ( $params{easting}, $params{northing} ) = _ll_to_en( $params{latitude}, $params{longitude} ); - # FIXME - convert all pins to lat, lng - # all the pins are currently [lat, lng, colour] - convert them - foreach my $pin ( @{ $params{pins} ||= [] } ) { - my ( $lat, $lon ) = ( $pin->[0], $pin->[1] ); - my ( $e, $n ) = _ll_to_en( $lat, $lon ); - ( $pin->[0], $pin->[1] ) = ( $e, $n ); - } - # X/Y tile co-ords may be overridden in the query string my @vars = qw(x y); my %input = map { $_ => $c->req->params->{$_} || '' } @vars; @@ -65,17 +57,10 @@ sub display_map { my ($x, $y, $px, $py) = os_to_px_with_adjust($c, $params{easting}, $params{northing}, $input{x}, $input{y}); - my @pins; foreach my $pin (@{$params{pins}}) { - my $pin_x = os_to_px($pin->[0], $x); - my $pin_y = os_to_px($pin->[1], $y, 1); - push @pins, { - px => $pin_x, - py => $pin_y, - col => $pin->[2], - id => $pin->[3], - title => $pin->[4], - }; + my ( $e, $n ) = _ll_to_en( $pin->{latitude}, $pin->{longitude} ); + $pin->{px} = os_to_px($e, $x); + $pin->{py} = os_to_px($n, $y, 1); } $px = defined($px) ? $mid_point - $px : 0; @@ -88,7 +73,7 @@ sub display_map { my $tileids = RABX::unserialise($tiles); $c->stash->{map} = { type => 'tilma/original', - pins => \@pins, + pins => $params{pins}, tiles => $tiles, clickable => $params{type}, url => $url, |