diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-06-05 12:23:59 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-06-06 17:01:56 +0100 |
commit | de36c49d1ff2bf7858c8cc8762c4c7b9d05c9cb3 (patch) | |
tree | e873ae9c8db5518e89468a14908d0852bcb5252c /web/js/map-OpenLayers.js | |
parent | cbf69359d101c0e5ca6058f84674ef04a3c8632e (diff) |
Fix pointer event issue selecting pin on map.
On a mobile device that implements pointer events, there are two events that
can happen on an /around page – touching the map starts a new report (or goes
back to the map if already on a report page); touching a pin pulls in that
report’s page. The map touch, which uses an OpenLayers.Handler.Click, operates
on click, whereas the pin touch, which uses an OpenLayers.Handler.Feature,
operates on touchstart. Neither event cancels the other, which means you can
end up either starting a new report, and then it tries to pull in an undefined
pin ID report and errors, or the pin report loads and then you instantly go
back to the map page.
In order to work around this, we disable the map click control when the feature
control event starts, and reactivate once the report data has been loaded.
Diffstat (limited to 'web/js/map-OpenLayers.js')
-rw-r--r-- | web/js/map-OpenLayers.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 2e62336ed..868e2333e 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -311,6 +311,9 @@ $.extend(fixmystreet.utils, { return; } + // clickFeature operates on touchstart, we do not want the map click taking place on touchend! + fixmystreet.maps.click_control.deactivate(); + // All of this, just so that ctrl/cmd-click on a pin works?! var event; if (typeof window.MouseEvent === 'function') { @@ -720,7 +723,7 @@ $.extend(fixmystreet.utils, { } if (document.getElementById('mapForm')) { - var click = new OpenLayers.Control.Click(); + var click = fixmystreet.maps.click_control = new OpenLayers.Control.Click(); fixmystreet.map.addControl(click); click.activate(); } |