aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/cobrands/northamptonshire/assets.js46
1 files changed, 42 insertions, 4 deletions
diff --git a/web/cobrands/northamptonshire/assets.js b/web/cobrands/northamptonshire/assets.js
index 2b35de674..ab6212602 100644
--- a/web/cobrands/northamptonshire/assets.js
+++ b/web/cobrands/northamptonshire/assets.js
@@ -312,9 +312,47 @@ var layers = [
},
];
+var northants_defaults = $.extend(true, {}, fixmystreet.assets.alloy_defaults, {
+ select_action: true,
+ actions: {
+ asset_found: function(asset) {
+ var lonlat = asset.geometry.getBounds().getCenterLonLat();
+ // Features considered overlapping if within 1M of each other
+ // TODO: Should zoom/marker size be considered when determining if markers overlap?
+ var overlap_threshold = 1;
+ var overlapping_features = this.getFeaturesWithinDistance(
+ new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat),
+ overlap_threshold
+ );
+ if (overlapping_features.length > 1) {
+ // TODO: In an ideal world we'd be able to show the user a photo of each
+ // of the assets and ask them to pick one.
+ // However the Alloy API requires authentication for photos which we
+ // don't have in FMS JS. Instead, we tell the user there are multiple things here
+ // and ask them to describe the asset in the description field.
+ var $p = $("#overlapping_features_msg");
+ if (!$p.length) {
+ $p = $("<p id='overlapping_features_msg' class='hidden box-warning'>" +
+ "There is more than one <span class='overlapping_item_name'></span> at this location. " +
+ "Please describe which <span class='overlapping_item_name'></span> has the problem clearly.</p>");
+ $p.insertAfter('#form_category_row');
+ }
+ $p.find(".overlapping_item_name").text(this.fixmystreet.asset_item);
+ $p.removeClass('hidden');
+ } else {
+ $("#overlapping_features_msg").addClass('hidden');
+ }
+
+ },
+ asset_not_found: function() {
+ $("#overlapping_features_msg").addClass('hidden');
+ }
+ }
+});
+
$.each(layers, function(index, layer) {
if ( layer.categories ) {
- fixmystreet.assets.add($.extend(true, {}, fixmystreet.assets.alloy_defaults, {
+ fixmystreet.assets.add($.extend(true, {}, northants_defaults, {
protocol: OpenLayers.Protocol.Alloy,
http_options: {
layerid: layer.layer,
@@ -335,7 +373,7 @@ $.each(layers, function(index, layer) {
});
fixmystreet.assets.add($.extend(true, {}, fixmystreet.assets.alloy_defaults, {
- protocol: OpenLayers.Protocol.Alloy,
+ protocol_class: OpenLayers.Protocol.Alloy,
http_options: {
layerid: 221,
layerVersion: '221.4-',
@@ -364,7 +402,7 @@ var barrier_style = new OpenLayers.Style({
strokeWidth: 4
});
-fixmystreet.assets.add($.extend(true, {}, northants_defaults, {
+fixmystreet.assets.add($.extend(true, {}, fixmystreet.assets.alloy_defaults, {
protocol_class: OpenLayers.Protocol.Alloy,
http_options: {
layerid: 230,
@@ -397,7 +435,7 @@ var highways_style = new OpenLayers.Style({
});
fixmystreet.assets.add($.extend(true, {}, fixmystreet.assets.alloy_defaults, {
- protocol: OpenLayers.Protocol.Alloy,
+ protocol_class: OpenLayers.Protocol.Alloy,
http_options: {
layerid: 308,
layerVersion: '308.8-',