diff options
Diffstat (limited to 'www/js')
-rw-r--r-- | www/js/map-OpenLayers.js | 32 | ||||
-rw-r--r-- | www/js/views/around.js | 13 |
2 files changed, 44 insertions, 1 deletions
diff --git a/www/js/map-OpenLayers.js b/www/js/map-OpenLayers.js index 2be1f48..0dcfe7d 100644 --- a/www/js/map-OpenLayers.js +++ b/www/js/map-OpenLayers.js @@ -220,6 +220,7 @@ function fixmystreet_onload() { }); if (fixmystreet.page == 'around' ) { + fixmystreet.map.addControl( new OpenLayers.Control.ActionAfterDrag({'autoActivate': true}) ); fixmystreet.map.addControl( new OpenLayers.Control.Crosshairs(null) ); } } @@ -433,3 +434,34 @@ OpenLayers.Format.FixMyStreet = OpenLayers.Class(OpenLayers.Format.JSON, { }, CLASS_NAME: "OpenLayers.Format.FixMyStreet" }); + +OpenLayers.Control.ActionAfterDrag = OpenLayers.Class(OpenLayers.Control, { + + defaultHandlerOptions: { + 'stopDown': false + /* important, otherwise it prevent the click-drag event from + triggering the normal click-drag behavior on the map to pan it */ + }, + + initialize: function(options) { + this.handlerOptions = OpenLayers.Util.extend( + {}, this.defaultHandlerOptions + ); + OpenLayers.Control.prototype.initialize.apply( + this, arguments + ); + this.handler = new OpenLayers.Handler.Drag( + this, { + 'up': this.onDragEnd //could be also 'move', 'up' or 'out' + }, this.handlerOptions + ); + }, + + onDragEnd: function(evt) { + // do something when the user clic on the map (so on drag start) + console.log('drag ended'); + if ( $('#confirm').css('display') == 'block' ) { + $('#reposition').show(); + } + } +}); diff --git a/www/js/views/around.js b/www/js/views/around.js index 2b17ce6..057241e 100644 --- a/www/js/views/around.js +++ b/www/js/views/around.js @@ -16,6 +16,7 @@ 'vclick #cancel': 'onClickCancel', 'vclick #confirm': 'onClickReport', 'vclick #mark-here': 'onClickMark', + 'vclick #reposition': 'onClickReposition', 'vclick a.address': 'goAddress', 'submit #postcodeForm': 'search' }, @@ -179,7 +180,17 @@ } fixmystreet.bbox_strategy.activate(); fixmystreet.select_feature.activate(); - fixmystreet_activate_drag(); + }, + + onClickReposition: function(e) { + e.preventDefault(); + var lonlat = this.getCrossHairPosition(); + lonlat.transform( + new OpenLayers.Projection("EPSG:4326"), + fixmystreet.map.getProjectionObject() + ); + fixmystreet.markers.features[0].move(lonlat); + $('#reposition').hide(); }, onClickReport: function() { |