diff options
author | Struan Donald <struan@exo.org.uk> | 2018-04-03 12:22:21 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-08-03 21:33:13 +0100 |
commit | d90f4c2587380831d3cb6ed431a0c9c002575702 (patch) | |
tree | 0937be02104281e5b24ecd96aac7fd3cc2baca16 /web/js/map-OpenLayers.js | |
parent | f0a20065e8129f9da5d48a8f29a37755de61e4bb (diff) |
Allow asset layer display to be body dependent.
Return a list of associated bodies on around/new pages and in category ajax
calls, and use that when deciding whether to show/hide layers. If the layer
has no body information, then we show it as before, maybe based on category
selected; if it does, it is only shown if the layer body matches the bodies
for the point.
As part of this create a new VectorAsset class to handle all the visibility
changes for asset layers as it makes it a bit tidier.
Diffstat (limited to 'web/js/map-OpenLayers.js')
-rw-r--r-- | web/js/map-OpenLayers.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 3c9e3fb91..07acf248c 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -27,6 +27,48 @@ $.extend(fixmystreet.utils, { return out.join(','); }, + // https://stackoverflow.com/questions/1293147/javascript-code-to-parse-csv-data/1293163#1293163 + csv_to_array: function( strData, strDelimiter ) { + strDelimiter = (strDelimiter || ","); + + var objPattern = new RegExp( + ( + "(\\" + strDelimiter + "|\\r?\\n|\\r|^)" + + "(?:\"([^\"]*(?:\"\"[^\"]*)*)\"|" + + "([^\"\\" + strDelimiter + "\\r\\n]*))" + ), + "gi" + ); + + var arrData = [[]]; + + var arrMatches = objPattern.exec( strData ); + while (arrMatches) { + + var strMatchedDelimiter = arrMatches[ 1 ]; + + if ( strMatchedDelimiter.length && + strMatchedDelimiter !== strDelimiter) { + arrData.push( [] ); + } + + var strMatchedValue; + if (arrMatches[ 2 ]) { + strMatchedValue = arrMatches[ 2 ].replace( + new RegExp( "\"\"", "g" ), + "\"" + ); + } else { + strMatchedValue = arrMatches[ 3 ]; + } + + arrData[ arrData.length - 1 ].push( strMatchedValue ); + arrMatches = objPattern.exec( strData ); + } + + return( arrData ); + }, + parse_query_string: function() { var qs = {}; if (!location.search) { |