diff options
-rw-r--r-- | templates/web/fixmystreet.com/footer_extra_js.html | 1 | ||||
-rw-r--r-- | web/cobrands/eastsussex/assets.js | 97 |
2 files changed, 98 insertions, 0 deletions
diff --git a/templates/web/fixmystreet.com/footer_extra_js.html b/templates/web/fixmystreet.com/footer_extra_js.html index d2fe1e588..289e230e7 100644 --- a/templates/web/fixmystreet.com/footer_extra_js.html +++ b/templates/web/fixmystreet.com/footer_extra_js.html @@ -11,6 +11,7 @@ IF bodyclass.match('mappage'); scripts.push( version('/cobrands/bromley/assets.js') ); scripts.push( version('/cobrands/buckinghamshire/assets.js') ); scripts.push( version('/cobrands/cheshireeast/assets.js') ); + scripts.push( version('/cobrands/eastsussex/assets.js') ); scripts.push( version('/cobrands/isleofwight/assets.js') ); scripts.push( version('/cobrands/lincolnshire/assets.js') ); scripts.push( version('/cobrands/northamptonshire/assets.js') ); diff --git a/web/cobrands/eastsussex/assets.js b/web/cobrands/eastsussex/assets.js new file mode 100644 index 000000000..a84ad11e9 --- /dev/null +++ b/web/cobrands/eastsussex/assets.js @@ -0,0 +1,97 @@ +(function(){ + +if (!fixmystreet.maps) { + return; +} + + +OpenLayers.Format.EastSussex = OpenLayers.Class(OpenLayers.Format.JSON, { + read: function(json, type, filter) { + var obj = json; + if (typeof json == "string") { + obj = OpenLayers.Format.JSON.prototype.read.apply(this, + [json, filter]); + } + + var results = []; + for (var i=0, len=obj.length; i<len; i++) { + var item = obj[i]; + var geom = new OpenLayers.Geometry.Point(item.Mid_Location__c.longitude, item.Mid_Location__c.latitude); + var vec = new OpenLayers.Feature.Vector(geom, item); + results.push(vec); + } + + return results; + }, + CLASS_NAME: "OpenLayers.Format.EastSussex" +}); + +OpenLayers.Protocol.EastSussex = OpenLayers.Class(OpenLayers.Protocol.HTTP, { + read: function(options) { + OpenLayers.Protocol.prototype.read.apply(this, arguments); + options = options || {}; + options.params = OpenLayers.Util.applyDefaults( + options.params, this.options.params); + options = OpenLayers.Util.applyDefaults(options, this.options); + var types = options.types.join('&types='); + var coords = fixmystreet.map.getCenterWGS84(); + options.url = options.url + '?longitude=' + coords.lat + '&latitude=' + coords.lon + '&types=' + types; + var resp = new OpenLayers.Protocol.Response({requestType: "read"}); + resp.priv = OpenLayers.Request.GET({ + url: options.url, + callback: this.createCallback(this.handleRead, resp, options), + params: options.params, + headers: options.headers + }); + }, + CLASS_NAME: "OpenLayers.Protocol.EastSussex" +}); + +var defaults = { + http_options: { + url: fixmystreet.staging ? "https://tilma.staging.mysociety.org/proxy/escc/" : "https://tilma.mysociety.org/proxy/escc/" + }, + max_resolution: 1.194328566789627, + geometryName: 'msGeometry', + srsName: "EPSG:4326", + body: "East Sussex County Council", + format_class: OpenLayers.Format.EastSussex, + protocol_class: OpenLayers.Protocol.EastSussex, + asset_id_field: 'asset_id', + attributes: { + asset_id: 'id' + } +}; + +fixmystreet.assets.add(defaults, { + http_options: { + types: [ + "Bollard", "Central Refuge Beacon", "External Illuminated Sign", "Floodlight", "Internal Illuminated Sign", "Lighting Column", "Reflect Bollard", "Safety bollards", "Solar Bollard", "Subway Unit", "Zebra X Beacon" + ] + }, + asset_item: 'street light', + asset_category: ["Burning By Day", "Intermittent", "Knocked Down", "Lamp Dim", "Vandalism", "Wires Exposed"] +}); + +fixmystreet.assets.add(defaults, { + http_options: { + types: [ + "Grit bin" + ] + }, + asset_item: 'grit bin', + asset_category: ["Broken Grit Bin", "Request To Refill Grit Bin"] +}); + +fixmystreet.assets.add(defaults, { + http_options: { + types: [ + "Filter Drain", "Gully and Catchpit" + ] + }, + asset_id_field: 'id', + asset_item: 'drain', + asset_category: ["Blocked Drain", "Broken Drain Cover", "Ditches", "Missing Drain Cover"] +}); + +})(); |