aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/map-OpenLayers.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/js/map-OpenLayers.js')
-rw-r--r--web/js/map-OpenLayers.js72
1 files changed, 44 insertions, 28 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index d98994d84..85ab09889 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -70,26 +70,30 @@ function fms_markers_list(pins, transform) {
}
function fixmystreet_onload() {
- if ( fixmystreet.area ) {
- var area = new OpenLayers.Layer.Vector("KML", {
- strategies: [ new OpenLayers.Strategy.Fixed() ],
- protocol: new OpenLayers.Protocol.HTTP({
- url: "/mapit/area/" + fixmystreet.area + ".kml?simplify_tolerance=0.0001",
- format: new OpenLayers.Format.KML()
- })
- });
- fixmystreet.map.addLayer(area);
- area.events.register('loadend', null, function(a,b,c) {
- var bounds = area.getDataExtent();
- if (bounds) {
- var center = bounds.getCenterLonLat();
- var z = fixmystreet.map.getZoomForExtent(bounds);
- if ( z < 13 && $('html').hasClass('mobile') ) {
- z = 13;
- }
- fixmystreet.map.setCenter(center, z, false, true);
+ if ( fixmystreet.area.length ) {
+ for (var i=0; i<fixmystreet.area.length; i++) {
+ var area = new OpenLayers.Layer.Vector("KML", {
+ strategies: [ new OpenLayers.Strategy.Fixed() ],
+ protocol: new OpenLayers.Protocol.HTTP({
+ url: "/mapit/area/" + fixmystreet.area[i] + ".kml?simplify_tolerance=0.0001",
+ format: new OpenLayers.Format.KML()
+ })
+ });
+ fixmystreet.map.addLayer(area);
+ if ( fixmystreet.area.length == 1 ) {
+ area.events.register('loadend', null, function(a,b,c) {
+ var bounds = area.getDataExtent();
+ if (bounds) {
+ var center = bounds.getCenterLonLat();
+ var z = fixmystreet.map.getZoomForExtent(bounds);
+ if ( z < 13 && $('html').hasClass('mobile') ) {
+ z = 13;
+ }
+ fixmystreet.map.setCenter(center, z, false, true);
+ }
+ });
}
- });
+ }
}
var pin_layer_style_map = new OpenLayers.StyleMap({
@@ -133,7 +137,7 @@ function fixmystreet_onload() {
styleMap: pin_layer_style_map
};
if (fixmystreet.page == 'around') {
- fixmystreet.bbox_strategy = new OpenLayers.Strategy.BBOX({ ratio: 1 });
+ fixmystreet.bbox_strategy = fixmystreet.bbox_strategy || new OpenLayers.Strategy.BBOX({ ratio: 1 });
pin_layer_options.strategies = [ fixmystreet.bbox_strategy ];
pin_layer_options.protocol = new OpenLayers.Protocol.HTTP({
url: '/ajax',
@@ -246,23 +250,35 @@ function fixmystreet_onload() {
$(function(){
- set_map_config();
+ // Set specific map config - some other JS included in the
+ // template should define this
+ set_map_config();
- fixmystreet.map = new OpenLayers.Map("map", {
- controls: fixmystreet.controls,
- displayProjection: new OpenLayers.Projection("EPSG:4326")
- });
+ // Create the basics of the map
+ fixmystreet.map = new OpenLayers.Map(
+ "map", OpenLayers.Util.extend({
+ controls: fixmystreet.controls,
+ displayProjection: new OpenLayers.Projection("EPSG:4326")
+ }, fixmystreet.map_options)
+ );
if ($('html').hasClass('mobile') && fixmystreet.page == 'around') {
$('#fms_pan_zoom').css({ top: '2.75em !important' });
}
+ // Set it up our way
fixmystreet.layer_options = OpenLayers.Util.extend({
zoomOffset: fixmystreet.zoomOffset,
transitionEffect: 'resize',
numZoomLevels: fixmystreet.numZoomLevels
}, fixmystreet.layer_options);
- var layer = new fixmystreet.map_type("", fixmystreet.layer_options);
+
+ var layer;
+ if (fixmystreet.layer_options.matrixIds) {
+ layer = new fixmystreet.map_type(fixmystreet.layer_options);
+ } else {
+ layer = new fixmystreet.map_type("", fixmystreet.layer_options);
+ }
fixmystreet.map.addLayer(layer);
if (!fixmystreet.map.getCenter()) {
@@ -333,7 +349,7 @@ $(function(){
$('#sub_map_links').show();
//only on mobile
$('#mob_sub_map_links').remove();
- $('.mobile-map-banner').text('Place pin on map');
+ $('.mobile-map-banner').html('<a href="/">Home</a> Place pin on map');
fixmystreet.page = 'around';
});
@@ -528,7 +544,7 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
).css({ position: 'relative', width: width, height: height, marginBottom: '1em' });
// Making it relative here makes it much easier to do the scrolling later
- $('.mobile-map-banner').text('Right place?');
+ $('.mobile-map-banner').html('<a href="/">Home</a> Right place?');
// mobile user clicks 'ok' on map
$('#mob_ok').toggle(function(){