aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/cobrands/bathnes/js.js47
-rw-r--r--web/cobrands/bathnes/staff.js40
-rw-r--r--web/cobrands/fixmystreet/assets.js52
-rw-r--r--web/vendor/OpenLayers/OpenLayers.bathnes.js5
4 files changed, 117 insertions, 27 deletions
diff --git a/web/cobrands/bathnes/js.js b/web/cobrands/bathnes/js.js
index 84c9c56f5..71077ed43 100644
--- a/web/cobrands/bathnes/js.js
+++ b/web/cobrands/bathnes/js.js
@@ -45,6 +45,53 @@ fixmystreet.assets.add($.extend(true, {}, fixmystreet.maps.banes_defaults, {
}
}));
+fixmystreet.assets.add($.extend(true, {}, fixmystreet.maps.banes_defaults, {
+ http_options: {
+ params: {
+ TYPENAME: "ParksOpenSpacesAssets"
+ }
+ },
+ asset_category: [
+ 'Abandoned vehicles',
+ 'Dead animals',
+ 'Dog fouling',
+ 'Fly-tipping',
+ 'Graffiti',
+ 'Excessive or dangerous littering',
+ 'Needles',
+ 'Play area safety issue',
+ 'Damage to bins, benches, and infrastructure',
+ 'Allotment issue',
+ 'Trees and woodland',
+ 'Obstructive vegetation'
+ ],
+ asset_item: "park",
+ disable_pin_snapping: true,
+ stylemap: new OpenLayers.StyleMap({
+ 'default': new OpenLayers.Style({
+ fill: false,
+ stroke: false
+ })
+ }),
+ attributes: {
+ asset_details: function() {
+ var a = this.attributes;
+ return a.description + " " + a.assetid;
+ }
+ },
+ filter_key: 'category',
+ filter_value: [
+ 'Flower Beds',
+ 'Grass',
+ 'Hard',
+ 'Hedgerow',
+ 'Path',
+ 'Pitch',
+ 'Seats'
+ ],
+ name: "Parks and Grounds"
+}));
+
/*
diff --git a/web/cobrands/bathnes/staff.js b/web/cobrands/bathnes/staff.js
index 763761929..c6a8a9560 100644
--- a/web/cobrands/bathnes/staff.js
+++ b/web/cobrands/bathnes/staff.js
@@ -35,22 +35,34 @@ fixmystreet.assets.add($.extend(true, {}, fixmystreet.maps.banes_defaults, {
}));
-// Staff can actually see the adopted highways layer, so replace the invisible
-// stylemap of that layer.
-var highways_stylemap = new OpenLayers.StyleMap({
- 'default': new OpenLayers.Style({
- fill: true,
- fillOpacity: 0,
- // strokeColor: "#55BB00",
- strokeColor: "#FFFF00",
- strokeOpacity: 0.5,
- strokeWidth: 2,
- title: '${description}\n${notes}'
+// Some normally-invisible layers are visible to staff, so replace their
+// stylemaps accordingly.
+var replacement_stylemaps = {
+ "Adopted Highways": new OpenLayers.StyleMap({
+ 'default': new OpenLayers.Style({
+ fill: true,
+ fillOpacity: 0,
+ // strokeColor: "#55BB00",
+ strokeColor: "#FFFF00",
+ strokeOpacity: 0.5,
+ strokeWidth: 2,
+ title: '${description}\n${notes}'
+ })
+ }),
+ "Parks and Grounds": new OpenLayers.StyleMap({
+ 'default': new OpenLayers.Style({
+ fill: false,
+ strokeColor: "#008800",
+ strokeOpacity: 0.5,
+ strokeWidth: 2,
+ title: '${site_name}'
+ })
})
-});
+};
+
$.each(fixmystreet.assets.layers, function() {
- if (this.name == "Adopted Highways") {
- this.styleMap = highways_stylemap;
+ if (typeof replacement_stylemaps[this.name] !== 'undefined') {
+ this.styleMap = replacement_stylemaps[this.name];
}
});
diff --git a/web/cobrands/fixmystreet/assets.js b/web/cobrands/fixmystreet/assets.js
index 7e79776cd..77522fc6c 100644
--- a/web/cobrands/fixmystreet/assets.js
+++ b/web/cobrands/fixmystreet/assets.js
@@ -200,16 +200,7 @@ function asset_selected(e) {
// its own USRN which should take precedence.
$(fixmystreet).trigger('assets:selected', [ lonlat ]);
- // Set the extra field to the value of the selected feature
- $.each(this.fixmystreet.attributes, function (field_name, attribute_name) {
- var field_value;
- if (typeof attribute_name === 'function') {
- field_value = attribute_name.apply(e.feature);
- } else {
- field_value = e.feature.attributes[attribute_name];
- }
- $("#form_" + field_name).val(field_value);
- });
+ set_fields_from_attributes(this.fixmystreet.attributes, feature);
// Hide the normal markers layer to keep things simple, but
// move the green marker to the point of the click to stop
@@ -227,10 +218,26 @@ function asset_selected(e) {
function asset_unselected(e) {
fixmystreet.markers.setVisibility(true);
- $.each(this.fixmystreet.attributes, function (field_name, attribute_name) {
+ selected_feature = null;
+ clear_fields_for_attributes(this.fixmystreet.attributes);
+}
+
+function set_fields_from_attributes(attributes, feature) {
+ // Set the extra fields to the value of the selected feature
+ $.each(attributes, function (field_name, attribute_name) {
+ var $field = $("#form_" + field_name);
+ if (typeof attribute_name === 'function') {
+ $field.val(attribute_name.apply(feature));
+ } else {
+ $field.val(feature.attributes[attribute_name]);
+ }
+ });
+}
+
+function clear_fields_for_attributes(attributes) {
+ $.each(attributes, function (field_name, attribute_name) {
$("#form_" + field_name).val("");
});
- selected_feature = null;
}
function find_matching_feature(feature, layer, asset_id_field) {
@@ -528,6 +535,27 @@ fixmystreet.assets = {
select_feature_control = new OpenLayers.Control.SelectFeature( asset_layer );
asset_layer.events.register( 'featureselected', asset_layer, asset_selected);
asset_layer.events.register( 'featureunselected', asset_layer, asset_unselected);
+ if (options.disable_pin_snapping) {
+ // The pin is snapped to the centre of a feature by the select
+ // handler. We can stop this handler from running, and the pin
+ // being snapped, by returning false from a beforefeatureselected
+ // event handler. This handler does need to make sure the
+ // attributes of the clicked feature are applied to the extra
+ // details form fields first though.
+ asset_layer.events.register( 'beforefeatureselected', asset_layer, function(e) {
+ var attributes = this.fixmystreet.attributes;
+ set_fields_from_attributes(attributes, e.feature);
+
+ // The next click on the map may not be on an asset - so
+ // clear the fields for this layer when the pin is next
+ // updated. If it is on an asset then the fields will be
+ // set by whatever feature was selected.
+ $(fixmystreet).one('maps:update_pin', function() {
+ clear_fields_for_attributes(attributes);
+ });
+ return false;
+ });
+ }
// When panning/zooming the map check that this layer is still correctly shown
// and any selected marker is preserved
asset_layer.events.register( 'loadend', asset_layer, layer_loadend);
diff --git a/web/vendor/OpenLayers/OpenLayers.bathnes.js b/web/vendor/OpenLayers/OpenLayers.bathnes.js
index 4a2efc3ea..7fc6b790e 100644
--- a/web/vendor/OpenLayers/OpenLayers.bathnes.js
+++ b/web/vendor/OpenLayers/OpenLayers.bathnes.js
@@ -1684,4 +1684,7 @@ var center=mapBounds.getCenterLonLat();var dataWidth=mapBounds.getWidth()*this.r
var evt={filter:this.createFilter()};this.layer.events.triggerEvent("loadstart",evt);this.response=this.layer.protocol.read(OpenLayers.Util.applyDefaults({filter:evt.filter,callback:this.merge,scope:this},options));},createFilter:function(){var filter=new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.BBOX,value:this.bounds,projection:this.layer.projection});if(this.layer.filter){filter=new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.AND,filters:[this.layer.filter,filter]});}
return filter;},merge:function(resp){this.layer.destroyFeatures();if(resp.success()){var features=resp.features;if(features&&features.length>0){var remote=this.layer.projection;var local=this.layer.map.getProjectionObject();if(remote&&local&&!local.equals(remote)){var geom;for(var i=0,len=features.length;i<len;++i){geom=features[i].geometry;if(geom){geom.transform(remote,local);}}}
this.layer.addFeatures(features);}}else{this.bounds=null;}
-this.response=null;this.layer.events.triggerEvent("loadend",{response:resp});},CLASS_NAME:"OpenLayers.Strategy.BBOX"}); \ No newline at end of file
+this.response=null;this.layer.events.triggerEvent("loadend",{response:resp});},CLASS_NAME:"OpenLayers.Strategy.BBOX"});OpenLayers.Strategy.Filter=OpenLayers.Class(OpenLayers.Strategy,{filter:null,cache:null,caching:false,activate:function(){var activated=OpenLayers.Strategy.prototype.activate.apply(this,arguments);if(activated){this.cache=[];this.layer.events.on({"beforefeaturesadded":this.handleAdd,"beforefeaturesremoved":this.handleRemove,scope:this});}
+return activated;},deactivate:function(){this.cache=null;if(this.layer&&this.layer.events){this.layer.events.un({"beforefeaturesadded":this.handleAdd,"beforefeaturesremoved":this.handleRemove,scope:this});}
+return OpenLayers.Strategy.prototype.deactivate.apply(this,arguments);},handleAdd:function(event){if(!this.caching&&this.filter){var features=event.features;event.features=[];var feature;for(var i=0,ii=features.length;i<ii;++i){feature=features[i];if(this.filter.evaluate(feature)){event.features.push(feature);}else{this.cache.push(feature);}}}},handleRemove:function(event){if(!this.caching){this.cache=[];}},setFilter:function(filter){this.filter=filter;var previousCache=this.cache;this.cache=[];this.handleAdd({features:this.layer.features});if(this.cache.length>0){this.caching=true;this.layer.removeFeatures(this.cache.slice());this.caching=false;}
+if(previousCache.length>0){var event={features:previousCache};this.handleAdd(event);if(event.features.length>0){this.caching=true;this.layer.addFeatures(event.features);this.caching=false;}}},CLASS_NAME:"OpenLayers.Strategy.Filter"}); \ No newline at end of file