aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/dashboard.js
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2018-02-12 09:52:46 +0000
committerDave Arter <davea@mysociety.org>2018-02-22 11:30:24 +0000
commit01f7448201d11139ae3a31745b7f26965c7282e7 (patch)
treec26749c8e1c1f733e4d40d2ddc15d8d70a78a778 /web/js/dashboard.js
parent9c8493a3b785d2cda969533c76ac6cca26f3ca00 (diff)
Populate `usrn` field with USRN of clicked asset, if available
Some cobrands require reports to include the USRN of the clicked road. This commit allows an asset layer to be added and designated as a 'USRN provider' by setting its `usrn_field` property when calling fixmystreet.assets.add. Initially this feature used OpenLayers' getFeatureFromEvent method, however that doesn't work if the layer isn't topmost. This is because it uses the clicked element in the DOM to determine which feature was clicked. This doesn't work if the layer you're trying to get the feature from wasn't actually the DOM element that was clicked. Instead, we add a new method, OpenLayers.Layer.Vector.getFeatureAtPoint method which takes a Point object and iterates through the features' geometries to find the matching point. To make things a little more user-friendly, if an asset isn't clicked directly we find the closest to the clicked point and use that for the USRN. To accomplish this, this commit factors out the ‘select nearest asset’ code into a new method OpenLayers.Layer.Vector.getNearestFeature, which takes a Point and a distance threshold and finds the nearest feature.
Diffstat (limited to 'web/js/dashboard.js')
0 files changed, 0 insertions, 0 deletions