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.js49
1 files changed, 27 insertions, 22 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index 31f5f49d8..1d417f68e 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -22,6 +22,23 @@ $.extend(fixmystreet.utils, {
fixmystreet.maps = fixmystreet.maps || {};
+ var drag = {
+ activate: function() {
+ this._drag = new OpenLayers.Control.DragFeatureFMS( fixmystreet.markers, {
+ onComplete: function(feature, e) {
+ fixmystreet.update_pin( feature.geometry );
+ }
+ } );
+ fixmystreet.map.addControl( this._drag );
+ this._drag.activate();
+ },
+ deactivate: function() {
+ if (this._drag) {
+ this._drag.deactivate();
+ }
+ }
+ };
+
$.extend(fixmystreet.maps, {
// This function might be passed either an OpenLayers.LonLat (so has
// lon and lat), or an OpenLayers.Geometry.Point (so has x and y).
@@ -215,28 +232,12 @@ $.extend(fixmystreet.utils, {
}
});
- var drag = {
- activate: function() {
- this._drag = new OpenLayers.Control.DragFeatureFMS( fixmystreet.markers, {
- onComplete: function(feature, e) {
- fixmystreet.update_pin( feature.geometry );
- }
- } );
- fixmystreet.map.addControl( this._drag );
- this._drag.activate();
- },
- deactivate: function() {
- if (this._drag) {
- this._drag.deactivate();
- }
- }
- };
-
/* Make sure pins aren't going to reload just because we're zooming out,
* we already have the pins when the page loaded */
function zoomToBounds(bounds) {
if (!bounds) { return; }
- fixmystreet.markers.strategies[0].deactivate();
+ var strategy = fixmystreet.markers.strategies[0];
+ strategy.deactivate();
var center = bounds.getCenterLonLat();
var z = fixmystreet.map.getZoomForExtent(bounds);
if ( z < 13 && $('html').hasClass('mobile') ) {
@@ -244,9 +245,11 @@ $.extend(fixmystreet.utils, {
}
fixmystreet.map.setCenter(center, z);
// Reactivate the strategy and make it think it's done an update
- fixmystreet.markers.strategies[0].activate();
- fixmystreet.markers.strategies[0].calculateBounds();
- fixmystreet.markers.strategies[0].resolution = fixmystreet.map.getResolution();
+ strategy.activate();
+ if (strategy instanceof OpenLayers.Strategy.BBOX) {
+ strategy.calculateBounds();
+ strategy.resolution = fixmystreet.map.getResolution();
+ }
}
function sidebar_highlight(problem_id) {
@@ -862,8 +865,9 @@ OpenLayers.Protocol.FixMyStreet = OpenLayers.Class(OpenLayers.Protocol.HTTP, {
options.params[key] = val;
}
});
+ var page;
if (this.use_page) {
- var page = $('.pagination').data('page');
+ page = $('.pagination').data('page');
this.use_page = false;
} else if (this.initial_page) {
page = 1;
@@ -883,6 +887,7 @@ OpenLayers.Format.FixMyStreet = OpenLayers.Class(OpenLayers.Format.JSON, {
// Remove loading indicator
$('#loading-indicator').addClass('hidden');
$('#loading-indicator').attr('aria-hidden', true);
+ var obj;
if (typeof json == 'string') {
obj = OpenLayers.Format.JSON.prototype.read.apply(this, [json, filter]);
} else {