aboutsummaryrefslogtreecommitdiffstats
path: root/www/js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2013-06-21 13:52:57 +0100
committerStruan Donald <struan@exo.org.uk>2013-06-21 13:52:57 +0100
commitb41b9c7c6ebcc026aa90b88e7ca8f39b9057bddd (patch)
treee22f12ca4ca26c6952cd4f2db4f609693ac84c15 /www/js
parent914bc0b09ee87874d8d66f96747aacef5786d2a8 (diff)
add reposition button that appears if map is dragged after location has been set
Diffstat (limited to 'www/js')
-rw-r--r--www/js/map-OpenLayers.js32
-rw-r--r--www/js/views/around.js13
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() {