From 07f80c0a3f6feee3b7a2adcd8908a3c7a54a46d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20Schl=C3=BCter?= Date: Sun, 8 Feb 2015 12:00:37 +0100 Subject: [PATCH] Put out linebreaks in popups --- static/js/visualization.js | 40 +++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/static/js/visualization.js b/static/js/visualization.js index 1f10f19..6f56256 100644 --- a/static/js/visualization.js +++ b/static/js/visualization.js @@ -20,28 +20,6 @@ class Visualization { this._markers = [] } - /** - * Clear the map and render new markers - * @param {Array[Object]} incidents The incidents to be shown - * @return {Visualization} - * @chainable - */ - displayMarkers (incidents) { - if (incidents == null) - incidents = this.data - - this._markers.forEach(marker => { this.map.removeLayer(marker) }) - this._markers = [] - - incidents.forEach(incident => { - this._markers.push( - this._createMarker(incident).bindPopup(incident.description) - ) - }) - - return this - } - /** * Gets all currently active categories * @return {Array[string]} @@ -127,6 +105,24 @@ class Visualization { return this } + /** + * Clear the map and render new markers + * @param {Array[Object]} incidents The incidents to be shown + * @return {Visualization} + * @chainable + */ + displayMarkers (incidents) { + if (incidents == null) + incidents = this.data + + this._markers.forEach(marker => { this.map.removeLayer(marker) }) + this._markers = incidents.map(incident => { + return this._createMarker(incident).bindPopup(incident.description.replace(/\n/g, '
')) + }) + + return this + } + /** * Creates the correct marker for a single incident and adds it to the map * @param {Object} data A single incident