From d356df54727e4def3017b00b31f7cae85cf3a1b7 Mon Sep 17 00:00:00 2001 From: Fup Duck Date: Thu, 7 Sep 2017 12:40:19 +0200 Subject: [PATCH 1/5] allow markers to define different icons for different colors --- src/javascript/FormElements/IconElement.js | 5 +- src/javascript/Marker/GlyphiconMarker.js | 274 +++++++++++---------- src/javascript/Marker/Marker.js | 24 +- src/javascript/Util.js | 35 +++ 4 files changed, 196 insertions(+), 142 deletions(-) diff --git a/src/javascript/FormElements/IconElement.js b/src/javascript/FormElements/IconElement.js index 2943d09..07138d4 100644 --- a/src/javascript/FormElements/IconElement.js +++ b/src/javascript/FormElements/IconElement.js @@ -19,7 +19,7 @@ L.StyleEditor.formElements.IconElement = L.StyleEditor.formElements.FormElement. style: function () { this._styleSelectInputImage(this.options.selectBoxImage, this.options.styleEditorOptions.markerType.options.iconOptions.icon); - this._createColorSelect(this.options.styleEditorOptions.markerType.options.iconOptions.color); + this._createColorSelect(this.options.styleEditorOptions.markerType.options.iconOptions.iconColor); this._hideSelectOptions(); }, @@ -57,7 +57,6 @@ L.StyleEditor.formElements.IconElement = L.StyleEditor.formElements.FormElement. if (!this.options.selectOptions) { this.options.selectOptions = {}; } - if (color in this.options.selectOptions) return; @@ -65,7 +64,7 @@ L.StyleEditor.formElements.IconElement = L.StyleEditor.formElements.FormElement. var selectOptionWrapper = L.DomUtil.create('ul', this._selectOptionWrapperClasses, uiElement); - this.options.styleEditorOptions.markerType.options.markers.forEach(function (option) { + this.options.styleEditorOptions.util.getMarkersForColor(color).forEach(function (option) { var selectOption = L.DomUtil.create('li', this._selectOptionClasses, selectOptionWrapper); var selectImage = this._createSelectInputImage(selectOption); this._styleSelectInputImage(selectImage, option, color); diff --git a/src/javascript/Marker/GlyphiconMarker.js b/src/javascript/Marker/GlyphiconMarker.js index 36a973e..29c470c 100644 --- a/src/javascript/Marker/GlyphiconMarker.js +++ b/src/javascript/Marker/GlyphiconMarker.js @@ -71,141 +71,143 @@ L.StyleEditor.marker.GlyphiconMarker = L.StyleEditor.marker.Marker.extend({ }, options: { - markers: [ - 'glyphicon-plus', - 'glyphicon-asterisk', - 'glyphicon-plus', - 'glyphicon-euro', - 'glyphicon-minus', - 'glyphicon-cloud', - 'glyphicon-envelope', - 'glyphicon-pencil', - 'glyphicon-glass', - 'glyphicon-music', - 'glyphicon-search', - 'glyphicon-heart', - 'glyphicon-star', - 'glyphicon-star-empty', - 'glyphicon-user', - 'glyphicon-film', - 'glyphicon-th-large', - 'glyphicon-th', - 'glyphicon-th-list', - 'glyphicon-ok', - 'glyphicon-remove', - 'glyphicon-zoom-in', - 'glyphicon-zoom-out', - 'glyphicon-off', - 'glyphicon-signal', - 'glyphicon-cog', - 'glyphicon-trash', - 'glyphicon-home', - 'glyphicon-file', - 'glyphicon-time', - 'glyphicon-road', - 'glyphicon-download-alt', - 'glyphicon-download', - 'glyphicon-upload', - 'glyphicon-inbox', - 'glyphicon-play-circle', - 'glyphicon-repeat', - 'glyphicon-refresh', - 'glyphicon-list-alt', - 'glyphicon-lock', - 'glyphicon-flag', - 'glyphicon-headphones', - 'glyphicon-volume-off', - 'glyphicon-volume-down', - 'glyphicon-volume-up', - 'glyphicon-qrcode', - 'glyphicon-barcode', - 'glyphicon-tag', - 'glyphicon-tags', - 'glyphicon-book', - 'glyphicon-bookmark', - 'glyphicon-print', - 'glyphicon-camera', - 'glyphicon-font', - 'glyphicon-bold', - 'glyphicon-italic', - 'glyphicon-text-height', - 'glyphicon-text-width', - 'glyphicon-align-left', - 'glyphicon-align-center', - 'glyphicon-align-right', - 'glyphicon-align-justify', - 'glyphicon-list', - 'glyphicon-indent-left', - 'glyphicon-indent-right', - 'glyphicon-facetime-video', - 'glyphicon-picture', - 'glyphicon-map-marker', - 'glyphicon-adjust', - 'glyphicon-tint', - 'glyphicon-edit', - 'glyphicon-share', - 'glyphicon-check', - 'glyphicon-move', - 'glyphicon-chevron-right', - 'glyphicon-plus-sign', - 'glyphicon-minus-sign', - 'glyphicon-remove-sign', - 'glyphicon-ok-sign', - 'glyphicon-question-sign', - 'glyphicon-info-sign', - 'glyphicon-screenshot', - 'glyphicon-remove-circle', - 'glyphicon-ok-circle', - 'glyphicon-ban-circle', - 'glyphicon-arrow-left', - 'glyphicon-arrow-right', - 'glyphicon-arrow-up', - 'glyphicon-arrow-down', - 'glyphicon-share-alt', - 'glyphicon-resize-full', - 'glyphicon-resize-small', - 'glyphicon-exclamation-sign', - 'glyphicon-gift', - 'glyphicon-leaf', - 'glyphicon-fire', - 'glyphicon-eye-open', - 'glyphicon-eye-close', - 'glyphicon-warning-sign', - 'glyphicon-plane', - 'glyphicon-calendar', - 'glyphicon-random', - 'glyphicon-comment', - 'glyphicon-magnet', - 'glyphicon-chevron-up', - 'glyphicon-chevron-down', - 'glyphicon-retweet', - 'glyphicon-shopping-cart', - 'glyphicon-bullhorn', - 'glyphicon-bell', - 'glyphicon-certificate', - 'glyphicon-thumbs-up', - 'glyphicon-thumbs-down', - 'glyphicon-hand-right', - 'glyphicon-hand-left', - 'glyphicon-hand-up', - 'glyphicon-hand-down', - 'glyphicon-circle-arrow-right', - 'glyphicon-circle-arrow-left', - 'glyphicon-circle-arrow-up', - 'glyphicon-circle-arrow-down', - 'glyphicon-globe', - 'glyphicon-wrench', - 'glyphicon-tasks', - 'glyphicon-filter', - 'glyphicon-briefcase', - 'glyphicon-fullscreen', - 'glyphicon-dashboard', - 'glyphicon-paperclip', - 'glyphicon-heart-empty', - 'glyphicon-link', - 'glyphicon-phone', - 'glyphicon-pushpin', - 'glyphicon-usd' - ] + markers: { + default: [ + 'glyphicon-plus', + 'glyphicon-asterisk', + 'glyphicon-plus', + 'glyphicon-euro', + 'glyphicon-minus', + 'glyphicon-cloud', + 'glyphicon-envelope', + 'glyphicon-pencil', + 'glyphicon-glass', + 'glyphicon-music', + 'glyphicon-search', + 'glyphicon-heart', + 'glyphicon-star', + 'glyphicon-star-empty', + 'glyphicon-user', + 'glyphicon-film', + 'glyphicon-th-large', + 'glyphicon-th', + 'glyphicon-th-list', + 'glyphicon-ok', + 'glyphicon-remove', + 'glyphicon-zoom-in', + 'glyphicon-zoom-out', + 'glyphicon-off', + 'glyphicon-signal', + 'glyphicon-cog', + 'glyphicon-trash', + 'glyphicon-home', + 'glyphicon-file', + 'glyphicon-time', + 'glyphicon-road', + 'glyphicon-download-alt', + 'glyphicon-download', + 'glyphicon-upload', + 'glyphicon-inbox', + 'glyphicon-play-circle', + 'glyphicon-repeat', + 'glyphicon-refresh', + 'glyphicon-list-alt', + 'glyphicon-lock', + 'glyphicon-flag', + 'glyphicon-headphones', + 'glyphicon-volume-off', + 'glyphicon-volume-down', + 'glyphicon-volume-up', + 'glyphicon-qrcode', + 'glyphicon-barcode', + 'glyphicon-tag', + 'glyphicon-tags', + 'glyphicon-book', + 'glyphicon-bookmark', + 'glyphicon-print', + 'glyphicon-camera', + 'glyphicon-font', + 'glyphicon-bold', + 'glyphicon-italic', + 'glyphicon-text-height', + 'glyphicon-text-width', + 'glyphicon-align-left', + 'glyphicon-align-center', + 'glyphicon-align-right', + 'glyphicon-align-justify', + 'glyphicon-list', + 'glyphicon-indent-left', + 'glyphicon-indent-right', + 'glyphicon-facetime-video', + 'glyphicon-picture', + 'glyphicon-map-marker', + 'glyphicon-adjust', + 'glyphicon-tint', + 'glyphicon-edit', + 'glyphicon-share', + 'glyphicon-check', + 'glyphicon-move', + 'glyphicon-chevron-right', + 'glyphicon-plus-sign', + 'glyphicon-minus-sign', + 'glyphicon-remove-sign', + 'glyphicon-ok-sign', + 'glyphicon-question-sign', + 'glyphicon-info-sign', + 'glyphicon-screenshot', + 'glyphicon-remove-circle', + 'glyphicon-ok-circle', + 'glyphicon-ban-circle', + 'glyphicon-arrow-left', + 'glyphicon-arrow-right', + 'glyphicon-arrow-up', + 'glyphicon-arrow-down', + 'glyphicon-share-alt', + 'glyphicon-resize-full', + 'glyphicon-resize-small', + 'glyphicon-exclamation-sign', + 'glyphicon-gift', + 'glyphicon-leaf', + 'glyphicon-fire', + 'glyphicon-eye-open', + 'glyphicon-eye-close', + 'glyphicon-warning-sign', + 'glyphicon-plane', + 'glyphicon-calendar', + 'glyphicon-random', + 'glyphicon-comment', + 'glyphicon-magnet', + 'glyphicon-chevron-up', + 'glyphicon-chevron-down', + 'glyphicon-retweet', + 'glyphicon-shopping-cart', + 'glyphicon-bullhorn', + 'glyphicon-bell', + 'glyphicon-certificate', + 'glyphicon-thumbs-up', + 'glyphicon-thumbs-down', + 'glyphicon-hand-right', + 'glyphicon-hand-left', + 'glyphicon-hand-up', + 'glyphicon-hand-down', + 'glyphicon-circle-arrow-right', + 'glyphicon-circle-arrow-left', + 'glyphicon-circle-arrow-up', + 'glyphicon-circle-arrow-down', + 'glyphicon-globe', + 'glyphicon-wrench', + 'glyphicon-tasks', + 'glyphicon-filter', + 'glyphicon-briefcase', + 'glyphicon-fullscreen', + 'glyphicon-dashboard', + 'glyphicon-paperclip', + 'glyphicon-heart-empty', + 'glyphicon-link', + 'glyphicon-phone', + 'glyphicon-pushpin', + 'glyphicon-usd' + ] + } } }); diff --git a/src/javascript/Marker/Marker.js b/src/javascript/Marker/Marker.js index 5ffc37d..7e42034 100644 --- a/src/javascript/Marker/Marker.js +++ b/src/javascript/Marker/Marker.js @@ -17,10 +17,10 @@ L.StyleEditor.marker.Marker = L.Class.extend({ /** create new Marker and show it */ setNewMarker: function() { - var iconOptions = this.options.iconOptions; + var iconOptions = this._ensureMarkerIcon(this.options.iconOptions); if (iconOptions.iconSize && iconOptions.icon && iconOptions.iconColor) { - var newIcon = this.createMarkerIcon(iconOptions); + var newIcon = this._createMarkerIcon(iconOptions); var currentElement = this.options.styleEditorOptions.currentElement.target; currentElement.setIcon(newIcon); } @@ -28,7 +28,7 @@ L.StyleEditor.marker.Marker = L.Class.extend({ /** set styling options */ setStyle: function (styleOption, value) { - var iconOptions = this.options.iconOptions; + var iconOptions = this._ensureMarkerIcon(this.options.iconOptions); if(iconOptions[styleOption] != value) { iconOptions[styleOption] = value; this.setNewMarker(); @@ -38,6 +38,24 @@ L.StyleEditor.marker.Marker = L.Class.extend({ /** create HTML used to */ createSelectHTML: function(parentUiElement, iconOptions, icon) { this.createSelectHTML(parentUiElement, iconOptions, icon); + }, + + _createMarkerIcon: function(iconOptions) { + iconOptions = this._ensureMarkerIcon(iconOptions); + return this.createMarkerIcon(iconOptions); + }, + + _ensureMarkerIcon: function(iconOptions) { + var markers = this.options.styleEditorOptions.util.getMarkersForColor(iconOptions.iconColor); + + if (markers.includes(iconOptions.icon)) { + return iconOptions; + } + + iconOptions.icon = this.options.styleEditorOptions.util.getDefaultMarkerForColor(iconOptions.iconColor); + + return iconOptions; + } }); diff --git a/src/javascript/Util.js b/src/javascript/Util.js index d24a850..d5caba2 100644 --- a/src/javascript/Util.js +++ b/src/javascript/Util.js @@ -103,4 +103,39 @@ L.StyleEditor.Util = L.Class.extend({ return hex.length === 1 ? '0' + hex : hex; }, + /** get the markers for a specific color **/ + getMarkersForColor: function(color) { + var markers = this.options.styleEditorOptions.markerType.options.markers; + + // if only an array of markers is given return it + if (Array.isArray(markers)) { + return markers; + } + + // if color is specified return specific markers + color = this.rgbToHex(color); + if (Object.keys(markers).includes(color)) { + return markers[color]; + } + // return default markers + return markers.default; + }, + + /** get default marker for specific color **/ + getDefaultMarkerForColor: function(color) { + color = this.rgbToHex(color); + var defaultMarker = this.options.styleEditorOptions.markerType.options.defaultMarker; + var markers = this.getMarkersForColor(color); + + if (defaultMarker != undefined) { + if (typeof myVar === 'string' && markers.includes(defaultMarker)) { + return defaultMarker; + } + if (Object.keys(defaultMarker).includes(color)) { + return defaultMarker[color]; + } + } + return markers[0]; + } + }); From cfa585038e78a282e2e8f0dcf27e92f02f7d82fa Mon Sep 17 00:00:00 2001 From: Fup Duck Date: Thu, 7 Sep 2017 12:50:59 +0200 Subject: [PATCH 2/5] undo unnecessary change --- src/javascript/Marker/GlyphiconMarker.js | 274 +++++++++++------------ 1 file changed, 136 insertions(+), 138 deletions(-) diff --git a/src/javascript/Marker/GlyphiconMarker.js b/src/javascript/Marker/GlyphiconMarker.js index 29c470c..36a973e 100644 --- a/src/javascript/Marker/GlyphiconMarker.js +++ b/src/javascript/Marker/GlyphiconMarker.js @@ -71,143 +71,141 @@ L.StyleEditor.marker.GlyphiconMarker = L.StyleEditor.marker.Marker.extend({ }, options: { - markers: { - default: [ - 'glyphicon-plus', - 'glyphicon-asterisk', - 'glyphicon-plus', - 'glyphicon-euro', - 'glyphicon-minus', - 'glyphicon-cloud', - 'glyphicon-envelope', - 'glyphicon-pencil', - 'glyphicon-glass', - 'glyphicon-music', - 'glyphicon-search', - 'glyphicon-heart', - 'glyphicon-star', - 'glyphicon-star-empty', - 'glyphicon-user', - 'glyphicon-film', - 'glyphicon-th-large', - 'glyphicon-th', - 'glyphicon-th-list', - 'glyphicon-ok', - 'glyphicon-remove', - 'glyphicon-zoom-in', - 'glyphicon-zoom-out', - 'glyphicon-off', - 'glyphicon-signal', - 'glyphicon-cog', - 'glyphicon-trash', - 'glyphicon-home', - 'glyphicon-file', - 'glyphicon-time', - 'glyphicon-road', - 'glyphicon-download-alt', - 'glyphicon-download', - 'glyphicon-upload', - 'glyphicon-inbox', - 'glyphicon-play-circle', - 'glyphicon-repeat', - 'glyphicon-refresh', - 'glyphicon-list-alt', - 'glyphicon-lock', - 'glyphicon-flag', - 'glyphicon-headphones', - 'glyphicon-volume-off', - 'glyphicon-volume-down', - 'glyphicon-volume-up', - 'glyphicon-qrcode', - 'glyphicon-barcode', - 'glyphicon-tag', - 'glyphicon-tags', - 'glyphicon-book', - 'glyphicon-bookmark', - 'glyphicon-print', - 'glyphicon-camera', - 'glyphicon-font', - 'glyphicon-bold', - 'glyphicon-italic', - 'glyphicon-text-height', - 'glyphicon-text-width', - 'glyphicon-align-left', - 'glyphicon-align-center', - 'glyphicon-align-right', - 'glyphicon-align-justify', - 'glyphicon-list', - 'glyphicon-indent-left', - 'glyphicon-indent-right', - 'glyphicon-facetime-video', - 'glyphicon-picture', - 'glyphicon-map-marker', - 'glyphicon-adjust', - 'glyphicon-tint', - 'glyphicon-edit', - 'glyphicon-share', - 'glyphicon-check', - 'glyphicon-move', - 'glyphicon-chevron-right', - 'glyphicon-plus-sign', - 'glyphicon-minus-sign', - 'glyphicon-remove-sign', - 'glyphicon-ok-sign', - 'glyphicon-question-sign', - 'glyphicon-info-sign', - 'glyphicon-screenshot', - 'glyphicon-remove-circle', - 'glyphicon-ok-circle', - 'glyphicon-ban-circle', - 'glyphicon-arrow-left', - 'glyphicon-arrow-right', - 'glyphicon-arrow-up', - 'glyphicon-arrow-down', - 'glyphicon-share-alt', - 'glyphicon-resize-full', - 'glyphicon-resize-small', - 'glyphicon-exclamation-sign', - 'glyphicon-gift', - 'glyphicon-leaf', - 'glyphicon-fire', - 'glyphicon-eye-open', - 'glyphicon-eye-close', - 'glyphicon-warning-sign', - 'glyphicon-plane', - 'glyphicon-calendar', - 'glyphicon-random', - 'glyphicon-comment', - 'glyphicon-magnet', - 'glyphicon-chevron-up', - 'glyphicon-chevron-down', - 'glyphicon-retweet', - 'glyphicon-shopping-cart', - 'glyphicon-bullhorn', - 'glyphicon-bell', - 'glyphicon-certificate', - 'glyphicon-thumbs-up', - 'glyphicon-thumbs-down', - 'glyphicon-hand-right', - 'glyphicon-hand-left', - 'glyphicon-hand-up', - 'glyphicon-hand-down', - 'glyphicon-circle-arrow-right', - 'glyphicon-circle-arrow-left', - 'glyphicon-circle-arrow-up', - 'glyphicon-circle-arrow-down', - 'glyphicon-globe', - 'glyphicon-wrench', - 'glyphicon-tasks', - 'glyphicon-filter', - 'glyphicon-briefcase', - 'glyphicon-fullscreen', - 'glyphicon-dashboard', - 'glyphicon-paperclip', - 'glyphicon-heart-empty', - 'glyphicon-link', - 'glyphicon-phone', - 'glyphicon-pushpin', - 'glyphicon-usd' - ] - } + markers: [ + 'glyphicon-plus', + 'glyphicon-asterisk', + 'glyphicon-plus', + 'glyphicon-euro', + 'glyphicon-minus', + 'glyphicon-cloud', + 'glyphicon-envelope', + 'glyphicon-pencil', + 'glyphicon-glass', + 'glyphicon-music', + 'glyphicon-search', + 'glyphicon-heart', + 'glyphicon-star', + 'glyphicon-star-empty', + 'glyphicon-user', + 'glyphicon-film', + 'glyphicon-th-large', + 'glyphicon-th', + 'glyphicon-th-list', + 'glyphicon-ok', + 'glyphicon-remove', + 'glyphicon-zoom-in', + 'glyphicon-zoom-out', + 'glyphicon-off', + 'glyphicon-signal', + 'glyphicon-cog', + 'glyphicon-trash', + 'glyphicon-home', + 'glyphicon-file', + 'glyphicon-time', + 'glyphicon-road', + 'glyphicon-download-alt', + 'glyphicon-download', + 'glyphicon-upload', + 'glyphicon-inbox', + 'glyphicon-play-circle', + 'glyphicon-repeat', + 'glyphicon-refresh', + 'glyphicon-list-alt', + 'glyphicon-lock', + 'glyphicon-flag', + 'glyphicon-headphones', + 'glyphicon-volume-off', + 'glyphicon-volume-down', + 'glyphicon-volume-up', + 'glyphicon-qrcode', + 'glyphicon-barcode', + 'glyphicon-tag', + 'glyphicon-tags', + 'glyphicon-book', + 'glyphicon-bookmark', + 'glyphicon-print', + 'glyphicon-camera', + 'glyphicon-font', + 'glyphicon-bold', + 'glyphicon-italic', + 'glyphicon-text-height', + 'glyphicon-text-width', + 'glyphicon-align-left', + 'glyphicon-align-center', + 'glyphicon-align-right', + 'glyphicon-align-justify', + 'glyphicon-list', + 'glyphicon-indent-left', + 'glyphicon-indent-right', + 'glyphicon-facetime-video', + 'glyphicon-picture', + 'glyphicon-map-marker', + 'glyphicon-adjust', + 'glyphicon-tint', + 'glyphicon-edit', + 'glyphicon-share', + 'glyphicon-check', + 'glyphicon-move', + 'glyphicon-chevron-right', + 'glyphicon-plus-sign', + 'glyphicon-minus-sign', + 'glyphicon-remove-sign', + 'glyphicon-ok-sign', + 'glyphicon-question-sign', + 'glyphicon-info-sign', + 'glyphicon-screenshot', + 'glyphicon-remove-circle', + 'glyphicon-ok-circle', + 'glyphicon-ban-circle', + 'glyphicon-arrow-left', + 'glyphicon-arrow-right', + 'glyphicon-arrow-up', + 'glyphicon-arrow-down', + 'glyphicon-share-alt', + 'glyphicon-resize-full', + 'glyphicon-resize-small', + 'glyphicon-exclamation-sign', + 'glyphicon-gift', + 'glyphicon-leaf', + 'glyphicon-fire', + 'glyphicon-eye-open', + 'glyphicon-eye-close', + 'glyphicon-warning-sign', + 'glyphicon-plane', + 'glyphicon-calendar', + 'glyphicon-random', + 'glyphicon-comment', + 'glyphicon-magnet', + 'glyphicon-chevron-up', + 'glyphicon-chevron-down', + 'glyphicon-retweet', + 'glyphicon-shopping-cart', + 'glyphicon-bullhorn', + 'glyphicon-bell', + 'glyphicon-certificate', + 'glyphicon-thumbs-up', + 'glyphicon-thumbs-down', + 'glyphicon-hand-right', + 'glyphicon-hand-left', + 'glyphicon-hand-up', + 'glyphicon-hand-down', + 'glyphicon-circle-arrow-right', + 'glyphicon-circle-arrow-left', + 'glyphicon-circle-arrow-up', + 'glyphicon-circle-arrow-down', + 'glyphicon-globe', + 'glyphicon-wrench', + 'glyphicon-tasks', + 'glyphicon-filter', + 'glyphicon-briefcase', + 'glyphicon-fullscreen', + 'glyphicon-dashboard', + 'glyphicon-paperclip', + 'glyphicon-heart-empty', + 'glyphicon-link', + 'glyphicon-phone', + 'glyphicon-pushpin', + 'glyphicon-usd' + ] } }); From 4967990de123dbbbeb782e6b9ed3e0e1ec33e2ed Mon Sep 17 00:00:00 2001 From: Fup Duck Date: Thu, 7 Sep 2017 13:10:52 +0200 Subject: [PATCH 3/5] update min js --- dist/javascript/Leaflet.StyleEditor.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/javascript/Leaflet.StyleEditor.min.js b/dist/javascript/Leaflet.StyleEditor.min.js index bdf735e..7b48e95 100644 --- a/dist/javascript/Leaflet.StyleEditor.min.js +++ b/dist/javascript/Leaflet.StyleEditor.min.js @@ -1 +1 @@ -!function(t,e){"function"==typeof define&&define.amd?define(["leaflet"],t):"object"==typeof exports&&(module.exports=t(require("leaflet"))),void 0!==e&&e.L&&(e.L.StyleEditor=t(L))}(function(t){return{marker:{},forms:{},formElements:{}}},window),L.StyleEditor.Util=L.Class.extend({initialize:function(t){t&&L.setOptions(this,t)},fireChangeEvent:function(t){this.options.styleEditorOptions.map.fireEvent("styleeditor:changed",t)},hideElement:function(t){t&&L.DomUtil.addClass(t,"leaflet-styleeditor-hidden")},rgbToHex:function(t,e){if(t||(t=this.options.styleEditorOptions.defaultColor),0==t.indexOf("#"))return e&&t.replace("#",""),t;var o="";return t=t.substring(4).replace(")","").split(","),o=this._componentToHex(parseInt(t[0],10))+this._componentToHex(parseInt(t[1],10))+this._componentToHex(parseInt(t[2],10)),e?o:"#"+o},getCurrentElement:function(){return this.options.styleEditorOptions.currentElement?this.options.styleEditorOptions.currentElement.target:null},setCurrentElement:function(t){this.options.styleEditorOptions.currentElement.target=t},fillCurrentElement:function(){return this.getCurrentElement().options.fill},getStyle:function(t){var e=this.getCurrentElement().options[t];return e||null},setStyle:function(t,e){var o=this.getCurrentElement();if(o instanceof L.Marker)this.options.styleEditorOptions.markerType.setStyle(t,e);else{var i={};i[t]=e,o.setStyle(i)}this.fireChangeEvent(o)},showElement:function(t){t&&L.DomUtil.removeClass(t,"leaflet-styleeditor-hidden")},_componentToHex:function(t){var e=t.toString(16);return 1===e.length?"0"+e:e}}),L.StyleEditor.formElements.FormElement=L.Class.extend({initialize:function(t){t&&L.setOptions(this,t),this.options.styleOption&&(this.options.title=this.options.styleOption.charAt(0).toUpperCase()+this.options.styleOption.slice(1))},create:function(t){this.options.uiElement=L.DomUtil.create("div","leaflet-styleeditor-uiElement",t);this.createTitle(),this.createContent()},createTitle:function(){L.DomUtil.create("label","leaflet-styleeditor-label",this.options.uiElement).innerHTML=this.options.title+":"},createContent:function(){},show:function(){this.style(),this.showForm()},showForm:function(){this.options.styleEditorOptions.util.showElement(this.options.uiElement)},hide:function(){this.options.styleEditorOptions.util.hideElement(this.options.uiElement)},style:function(){},lostFocus:function(){},setStyle:function(t){var e=this.options.styleEditorOptions.util.getCurrentElement(),o=[e];e instanceof L.LayerGroup&&(o=Object.values(e._layers));for(var i=0;i=30?t[0]>=35?"l":"m":"s"},options:{markers:["circle-stroked","circle","square-stroked","square","triangle-stroked","triangle","star-stroked","star","cross","marker-stroked","marker","religious-jewish","religious-christian","religious-muslim","cemetery","rocket","airport","heliport","rail","rail-metro","rail-light","bus","fuel","parking","parking-garage","airfield","roadblock","ferry","harbor","bicycle","park","park2","museum","lodging","monument","zoo","garden","campsite","theatre","art-gallery","pitch","soccer","america-football","tennis","basketball","baseball","golf","swimming","cricket","skiing","school","college","library","post","fire-station","town-hall","police","prison","embassy","beer","restaurant","cafe","shop","fast-food","bar","bank","grocery","cinema","pharmacy","hospital","danger","industrial","warehouse","commercial","building","place-of-worship","alcohol-shop","logging","oil-well","slaughterhouse","dam","water","wetland","disability","telephone","emergency-telephone","toilets","waste-basket","music","land-use","city","town","village","farm","bakery","dog-park","lighthouse","clothing-store","polling-place","playground","entrance","heart","london-underground","minefield","rail-underground","rail-above","camera","laundry","car","suitcase","hairdresser","chemist","mobilephone","scooter"]}}),L.StyleEditor.marker.GlyphiconMarker=L.StyleEditor.marker.Marker.extend({getMarkerHtml:function(t,e,o){var i=this._getMarkerUrl(t,e);return'
'},createMarkerIcon:function(t){var e=t.iconSize;return new L.divIcon({className:"leaflet-styleeditor-glyphicon-marker-wrapper",html:this.getMarkerHtml(e,t.iconColor,t.icon),icon:t.icon,iconColor:t.iconColor,iconSize:e,iconAnchor:[e[0]/2,e[1]/2],popupAnchor:[0,-e[1]/2]})},setStyle:function(t,e){"icon"!=t&&(t="icon"+t.charAt(0).toUpperCase()+t.slice(1));var o=this.options.iconOptions;o[t]!=e&&(o[t]=e,this.setNewMarker())},createSelectHTML:function(t,e,o){t.innerHTML=this.getMarkerHtml("s",e.iconColor,o)},_size:function(t){return t[0]>=30?t[0]>=35?"l":"m":"s"},_getMarkerUrlForStyle:function(t){return this._getMarkerUrl(t.iconSize,t.iconColor,t.icon)},_getMarkerUrl:function(t,e,o){return"http://api.tiles.mapbox.com/v3/marker/pin-"+(t=this._size(t))+"+"+(e=0==e.indexOf("#")?e.replace("#",""):this.options.styleEditorOptions.util.rgbToHex(e,!0))+".png"},options:{markers:["glyphicon-plus","glyphicon-asterisk","glyphicon-plus","glyphicon-euro","glyphicon-minus","glyphicon-cloud","glyphicon-envelope","glyphicon-pencil","glyphicon-glass","glyphicon-music","glyphicon-search","glyphicon-heart","glyphicon-star","glyphicon-star-empty","glyphicon-user","glyphicon-film","glyphicon-th-large","glyphicon-th","glyphicon-th-list","glyphicon-ok","glyphicon-remove","glyphicon-zoom-in","glyphicon-zoom-out","glyphicon-off","glyphicon-signal","glyphicon-cog","glyphicon-trash","glyphicon-home","glyphicon-file","glyphicon-time","glyphicon-road","glyphicon-download-alt","glyphicon-download","glyphicon-upload","glyphicon-inbox","glyphicon-play-circle","glyphicon-repeat","glyphicon-refresh","glyphicon-list-alt","glyphicon-lock","glyphicon-flag","glyphicon-headphones","glyphicon-volume-off","glyphicon-volume-down","glyphicon-volume-up","glyphicon-qrcode","glyphicon-barcode","glyphicon-tag","glyphicon-tags","glyphicon-book","glyphicon-bookmark","glyphicon-print","glyphicon-camera","glyphicon-font","glyphicon-bold","glyphicon-italic","glyphicon-text-height","glyphicon-text-width","glyphicon-align-left","glyphicon-align-center","glyphicon-align-right","glyphicon-align-justify","glyphicon-list","glyphicon-indent-left","glyphicon-indent-right","glyphicon-facetime-video","glyphicon-picture","glyphicon-map-marker","glyphicon-adjust","glyphicon-tint","glyphicon-edit","glyphicon-share","glyphicon-check","glyphicon-move","glyphicon-chevron-right","glyphicon-plus-sign","glyphicon-minus-sign","glyphicon-remove-sign","glyphicon-ok-sign","glyphicon-question-sign","glyphicon-info-sign","glyphicon-screenshot","glyphicon-remove-circle","glyphicon-ok-circle","glyphicon-ban-circle","glyphicon-arrow-left","glyphicon-arrow-right","glyphicon-arrow-up","glyphicon-arrow-down","glyphicon-share-alt","glyphicon-resize-full","glyphicon-resize-small","glyphicon-exclamation-sign","glyphicon-gift","glyphicon-leaf","glyphicon-fire","glyphicon-eye-open","glyphicon-eye-close","glyphicon-warning-sign","glyphicon-plane","glyphicon-calendar","glyphicon-random","glyphicon-comment","glyphicon-magnet","glyphicon-chevron-up","glyphicon-chevron-down","glyphicon-retweet","glyphicon-shopping-cart","glyphicon-bullhorn","glyphicon-bell","glyphicon-certificate","glyphicon-thumbs-up","glyphicon-thumbs-down","glyphicon-hand-right","glyphicon-hand-left","glyphicon-hand-up","glyphicon-hand-down","glyphicon-circle-arrow-right","glyphicon-circle-arrow-left","glyphicon-circle-arrow-up","glyphicon-circle-arrow-down","glyphicon-globe","glyphicon-wrench","glyphicon-tasks","glyphicon-filter","glyphicon-briefcase","glyphicon-fullscreen","glyphicon-dashboard","glyphicon-paperclip","glyphicon-heart-empty","glyphicon-link","glyphicon-phone","glyphicon-pushpin","glyphicon-usd"]}}),L.StyleForm=L.Class.extend({initialize:function(t){L.setOptions(this,t),this.createMarkerForm(),this.createGeometryForm(),this.addDOMEvents()},addDOMEvents:function(){L.DomEvent.addListener(this.options.styleEditorOptions.map,"click",this.lostFocus,this),L.DomEvent.addListener(this.options.styleEditorDiv,"click",this.lostFocus,this)},clearForm:function(){this.options.styleEditorOptions.markerForm.hide(),this.options.styleEditorOptions.geometryForm.hide()},createMarkerForm:function(){var t=L.DomUtil.create("div","leaflet-styleeditor-interior-marker",this.options.styleEditorInterior);this.options.styleEditorOptions.markerForm.create(t)},createGeometryForm:function(){var t=L.DomUtil.create("div","leaflet-styleeditor-interior-geometry",this.options.styleEditorInterior);this.options.styleEditorOptions.geometryForm.create(t)},showMarkerForm:function(){this.clearForm(),this.options.styleEditorOptions.markerForm.show()},showGeometryForm:function(){this.clearForm(),this.options.styleEditorOptions.geometryForm.show()},fireChangeEvent:function(t){this.options.styleEditorOptions.map.fireEvent("styleeditor:changed",t)},lostFocus:function(t){for(var e=t.target,o=0;o<10&&e;o++){if(e.className&&L.DomUtil.hasClass(e,"leaflet-styleeditor-interior"))return;e=e.parentNode}this.options.styleEditorOptions.markerForm.lostFocus(),this.options.styleEditorOptions.geometryForm.lostFocus()}}),L.Control.StyleEditor=L.Control.extend({options:{position:"topleft",enabled:!1,colorRamp:["#1abc9c","#2ecc71","#3498db","#9b59b6","#34495e","#16a085","#27ae60","#2980b9","#8e44ad","#2c3e50","#f1c40f","#e67e22","#e74c3c","#ecf0f1","#95a5a6","#f39c12","#d35400","#c0392b","#bdc3c7","#7f8c8d"],defaultColor:"f39c12",currentElement:null,markerType:L.StyleEditor.marker.DefaultMarker,geometryForm:L.StyleEditor.forms.GeometryForm,editLayers:[],layerGroups:[],openOnLeafletDraw:!0,showTooltip:!0,strings:{tooltip:"Click on the element you want to style",tooltipNext:"Choose another element you want to style"},useGrouping:!0},initialize:function(t){t&&L.setOptions(this,t),this.options.util=new L.StyleEditor.Util({styleEditorOptions:this.options}),this.options.markerType=new this.options.markerType({styleEditorOptions:this.options}),this.options.markerForm=new this.options.markerType.markerForm({styleEditorOptions:this.options}),this.options.geometryForm=new this.options.geometryForm({styleEditorOptions:this.options})},onAdd:function(t){return this.options.map=t,this.createUi()},createUi:function(){var t=this.options.controlDiv=L.DomUtil.create("div","leaflet-control-styleeditor leaflet-bar");(this.options.controlUI=L.DomUtil.create("a","leaflet-control-styleeditor-interior",t)).title="Style Editor";var e=this.options.styleEditorDiv=L.DomUtil.create("div","leaflet-styleeditor",this.options.map._container);this.options.styleEditorHeader=L.DomUtil.create("div","leaflet-styleeditor-header",e);var o=L.DomUtil.create("div","leaflet-styleeditor-interior",e);return this.addDomEvents(),this.addLeafletDrawEvents(),this.addButtons(),this.options.styleForm=new L.StyleForm({styleEditorDiv:e,styleEditorInterior:o,styleEditorOptions:this.options}),t},addDomEvents:function(){L.DomEvent.addListener(this.options.controlDiv,"click",function(t){this.clickHandler(t),t.stopPropagation()},this),L.DomEvent.addListener(this.options.controlDiv,"dblclick",function(t){t.stopPropagation()},this),L.DomEvent.addListener(this.options.styleEditorDiv,"click",L.DomEvent.stopPropagation),L.DomEvent.addListener(this.options.styleEditorDiv,"mouseenter",this.disableLeafletActions,this),L.DomEvent.addListener(this.options.styleEditorDiv,"mouseleave",this.enableLeafletActions,this)},addLeafletDrawEvents:function(){this.options.openOnLeafletDraw&&L.Control.Draw&&this.options.map.on("draw:created",function(t){this.initChangeStyle({target:t.layer})},this)},addButtons:function(){var t=L.DomUtil.create("button","leaflet-styleeditor-button styleeditor-nextBtn",this.options.styleEditorHeader);t.title=this.options.strings.tooltipNext,L.DomEvent.addListener(t,"click",function(t){this.hideEditor(),L.DomUtil.hasClass(this.options.controlUI,"enabled")&&this.createTooltip(),t.stopPropagation()},this)},clickHandler:function(t){this.options.enabled=!this.options.enabled,this.options.enabled?this.enable():(L.DomUtil.removeClass(this.options.controlUI,"enabled"),this.disable())},disableLeafletActions:function(){var t=this.options.map;t.dragging.disable(),t.touchZoom.disable(),t.doubleClickZoom.disable(),t.scrollWheelZoom.disable(),t.boxZoom.disable(),t.keyboard.disable()},enableLeafletActions:function(){var t=this.options.map;t.dragging.enable(),t.touchZoom.enable(),t.doubleClickZoom.enable(),t.scrollWheelZoom.enable(),t.boxZoom.enable(),t.keyboard.enable()},enable:function(){L.DomUtil.addClass(this.options.controlUI,"enabled"),this.options.map.eachLayer(this.addEditClickEvents,this),this.createTooltip()},disable:function(){this.options.editLayers.forEach(this.removeEditClickEvents,this),this.options.editLayers=[],this.options.layerGroups=[],this.hideEditor(),this.removeTooltip()},addEditClickEvents:function(t){if(this.options.useGrouping&&t instanceof L.LayerGroup)this.options.layerGroups.push(t);else if(t instanceof L.Marker||t instanceof L.Path){var e=t.on("click",this.initChangeStyle,this);this.options.editLayers.push(e)}},removeEditClickEvents:function(t){t.off("click",this.initChangeStyle,this)},hideEditor:function(){L.DomUtil.removeClass(this.options.styleEditorDiv,"editor-enabled")},showEditor:function(){var t=this.options.styleEditorDiv;L.DomUtil.hasClass(t,"editor-enabled")||L.DomUtil.addClass(t,"editor-enabled")},initChangeStyle:function(t){this.options.currentElement=this.options.useGrouping?this.getMatchingElement(t):t,this.showEditor(),this.removeTooltip(),t.target instanceof L.Marker?this.showMarkerForm():this.showGeometryForm()},showGeometryForm:function(){this.options.styleForm.showGeometryForm()},showMarkerForm:function(){this.options.styleForm.showMarkerForm()},createTooltip:function(){this.options.showTooltip&&(this.options.tooltipWrapper||(this.options.tooltipWrapper=L.DomUtil.create("div","leaflet-styleeditor-tooltip-wrapper",this.options.map.getContainer())),this.options.tooltip||(this.options.tooltip=L.DomUtil.create("div","leaflet-styleeditor-tooltip",this.options.tooltipWrapper)),this.options.tooltip.innerHTML=this.options.strings.tooltip)},getMatchingElement:function(t){for(var e=null,o=t.target,i=0;i=30?t[0]>=35?"l":"m":"s"},options:{markers:["circle-stroked","circle","square-stroked","square","triangle-stroked","triangle","star-stroked","star","cross","marker-stroked","marker","religious-jewish","religious-christian","religious-muslim","cemetery","rocket","airport","heliport","rail","rail-metro","rail-light","bus","fuel","parking","parking-garage","airfield","roadblock","ferry","harbor","bicycle","park","park2","museum","lodging","monument","zoo","garden","campsite","theatre","art-gallery","pitch","soccer","america-football","tennis","basketball","baseball","golf","swimming","cricket","skiing","school","college","library","post","fire-station","town-hall","police","prison","embassy","beer","restaurant","cafe","shop","fast-food","bar","bank","grocery","cinema","pharmacy","hospital","danger","industrial","warehouse","commercial","building","place-of-worship","alcohol-shop","logging","oil-well","slaughterhouse","dam","water","wetland","disability","telephone","emergency-telephone","toilets","waste-basket","music","land-use","city","town","village","farm","bakery","dog-park","lighthouse","clothing-store","polling-place","playground","entrance","heart","london-underground","minefield","rail-underground","rail-above","camera","laundry","car","suitcase","hairdresser","chemist","mobilephone","scooter"]}}),L.StyleEditor.marker.GlyphiconMarker=L.StyleEditor.marker.Marker.extend({getMarkerHtml:function(t,e,o){var i=this._getMarkerUrl(t,e);return'
'},createMarkerIcon:function(t){var e=t.iconSize;return new L.divIcon({className:"leaflet-styleeditor-glyphicon-marker-wrapper",html:this.getMarkerHtml(e,t.iconColor,t.icon),icon:t.icon,iconColor:t.iconColor,iconSize:e,iconAnchor:[e[0]/2,e[1]/2],popupAnchor:[0,-e[1]/2]})},setStyle:function(t,e){"icon"!=t&&(t="icon"+t.charAt(0).toUpperCase()+t.slice(1));var o=this.options.iconOptions;o[t]!=e&&(o[t]=e,this.setNewMarker())},createSelectHTML:function(t,e,o){t.innerHTML=this.getMarkerHtml("s",e.iconColor,o)},_size:function(t){return t[0]>=30?t[0]>=35?"l":"m":"s"},_getMarkerUrlForStyle:function(t){return this._getMarkerUrl(t.iconSize,t.iconColor,t.icon)},_getMarkerUrl:function(t,e,o){return"http://api.tiles.mapbox.com/v3/marker/pin-"+(t=this._size(t))+"+"+(e=0==e.indexOf("#")?e.replace("#",""):this.options.styleEditorOptions.util.rgbToHex(e,!0))+".png"},options:{markers:["glyphicon-plus","glyphicon-asterisk","glyphicon-plus","glyphicon-euro","glyphicon-minus","glyphicon-cloud","glyphicon-envelope","glyphicon-pencil","glyphicon-glass","glyphicon-music","glyphicon-search","glyphicon-heart","glyphicon-star","glyphicon-star-empty","glyphicon-user","glyphicon-film","glyphicon-th-large","glyphicon-th","glyphicon-th-list","glyphicon-ok","glyphicon-remove","glyphicon-zoom-in","glyphicon-zoom-out","glyphicon-off","glyphicon-signal","glyphicon-cog","glyphicon-trash","glyphicon-home","glyphicon-file","glyphicon-time","glyphicon-road","glyphicon-download-alt","glyphicon-download","glyphicon-upload","glyphicon-inbox","glyphicon-play-circle","glyphicon-repeat","glyphicon-refresh","glyphicon-list-alt","glyphicon-lock","glyphicon-flag","glyphicon-headphones","glyphicon-volume-off","glyphicon-volume-down","glyphicon-volume-up","glyphicon-qrcode","glyphicon-barcode","glyphicon-tag","glyphicon-tags","glyphicon-book","glyphicon-bookmark","glyphicon-print","glyphicon-camera","glyphicon-font","glyphicon-bold","glyphicon-italic","glyphicon-text-height","glyphicon-text-width","glyphicon-align-left","glyphicon-align-center","glyphicon-align-right","glyphicon-align-justify","glyphicon-list","glyphicon-indent-left","glyphicon-indent-right","glyphicon-facetime-video","glyphicon-picture","glyphicon-map-marker","glyphicon-adjust","glyphicon-tint","glyphicon-edit","glyphicon-share","glyphicon-check","glyphicon-move","glyphicon-chevron-right","glyphicon-plus-sign","glyphicon-minus-sign","glyphicon-remove-sign","glyphicon-ok-sign","glyphicon-question-sign","glyphicon-info-sign","glyphicon-screenshot","glyphicon-remove-circle","glyphicon-ok-circle","glyphicon-ban-circle","glyphicon-arrow-left","glyphicon-arrow-right","glyphicon-arrow-up","glyphicon-arrow-down","glyphicon-share-alt","glyphicon-resize-full","glyphicon-resize-small","glyphicon-exclamation-sign","glyphicon-gift","glyphicon-leaf","glyphicon-fire","glyphicon-eye-open","glyphicon-eye-close","glyphicon-warning-sign","glyphicon-plane","glyphicon-calendar","glyphicon-random","glyphicon-comment","glyphicon-magnet","glyphicon-chevron-up","glyphicon-chevron-down","glyphicon-retweet","glyphicon-shopping-cart","glyphicon-bullhorn","glyphicon-bell","glyphicon-certificate","glyphicon-thumbs-up","glyphicon-thumbs-down","glyphicon-hand-right","glyphicon-hand-left","glyphicon-hand-up","glyphicon-hand-down","glyphicon-circle-arrow-right","glyphicon-circle-arrow-left","glyphicon-circle-arrow-up","glyphicon-circle-arrow-down","glyphicon-globe","glyphicon-wrench","glyphicon-tasks","glyphicon-filter","glyphicon-briefcase","glyphicon-fullscreen","glyphicon-dashboard","glyphicon-paperclip","glyphicon-heart-empty","glyphicon-link","glyphicon-phone","glyphicon-pushpin","glyphicon-usd"]}}),L.StyleForm=L.Class.extend({initialize:function(t){L.setOptions(this,t),this.createMarkerForm(),this.createGeometryForm(),this.addDOMEvents()},addDOMEvents:function(){L.DomEvent.addListener(this.options.styleEditorOptions.map,"click",this.lostFocus,this),L.DomEvent.addListener(this.options.styleEditorDiv,"click",this.lostFocus,this)},clearForm:function(){this.options.styleEditorOptions.markerForm.hide(),this.options.styleEditorOptions.geometryForm.hide()},createMarkerForm:function(){var t=L.DomUtil.create("div","leaflet-styleeditor-interior-marker",this.options.styleEditorInterior);this.options.styleEditorOptions.markerForm.create(t)},createGeometryForm:function(){var t=L.DomUtil.create("div","leaflet-styleeditor-interior-geometry",this.options.styleEditorInterior);this.options.styleEditorOptions.geometryForm.create(t)},showMarkerForm:function(){this.clearForm(),this.options.styleEditorOptions.markerForm.show()},showGeometryForm:function(){this.clearForm(),this.options.styleEditorOptions.geometryForm.show()},fireChangeEvent:function(t){this.options.styleEditorOptions.map.fireEvent("styleeditor:changed",t)},lostFocus:function(t){for(var e=t.target,o=0;o<10&&e;o++){if(e.className&&L.DomUtil.hasClass(e,"leaflet-styleeditor-interior"))return;e=e.parentNode}this.options.styleEditorOptions.markerForm.lostFocus(),this.options.styleEditorOptions.geometryForm.lostFocus()}}),L.Control.StyleEditor=L.Control.extend({options:{position:"topleft",enabled:!1,colorRamp:["#1abc9c","#2ecc71","#3498db","#9b59b6","#34495e","#16a085","#27ae60","#2980b9","#8e44ad","#2c3e50","#f1c40f","#e67e22","#e74c3c","#ecf0f1","#95a5a6","#f39c12","#d35400","#c0392b","#bdc3c7","#7f8c8d"],defaultColor:"f39c12",currentElement:null,markerType:L.StyleEditor.marker.DefaultMarker,geometryForm:L.StyleEditor.forms.GeometryForm,editLayers:[],layerGroups:[],openOnLeafletDraw:!0,showTooltip:!0,strings:{tooltip:"Click on the element you want to style",tooltipNext:"Choose another element you want to style"},useGrouping:!0},initialize:function(t){t&&L.setOptions(this,t),this.options.util=new L.StyleEditor.Util({styleEditorOptions:this.options}),this.options.markerType=new this.options.markerType({styleEditorOptions:this.options}),this.options.markerForm=new this.options.markerType.markerForm({styleEditorOptions:this.options}),this.options.geometryForm=new this.options.geometryForm({styleEditorOptions:this.options})},onAdd:function(t){return this.options.map=t,this.createUi()},createUi:function(){var t=this.options.controlDiv=L.DomUtil.create("div","leaflet-control-styleeditor leaflet-bar");(this.options.controlUI=L.DomUtil.create("a","leaflet-control-styleeditor-interior",t)).title="Style Editor";var e=this.options.styleEditorDiv=L.DomUtil.create("div","leaflet-styleeditor",this.options.map._container);this.options.styleEditorHeader=L.DomUtil.create("div","leaflet-styleeditor-header",e);var o=L.DomUtil.create("div","leaflet-styleeditor-interior",e);return this.addDomEvents(),this.addLeafletDrawEvents(),this.addButtons(),this.options.styleForm=new L.StyleForm({styleEditorDiv:e,styleEditorInterior:o,styleEditorOptions:this.options}),t},addDomEvents:function(){L.DomEvent.addListener(this.options.controlDiv,"click",function(t){this.clickHandler(t),t.stopPropagation()},this),L.DomEvent.addListener(this.options.controlDiv,"dblclick",function(t){t.stopPropagation()},this),L.DomEvent.addListener(this.options.styleEditorDiv,"click",L.DomEvent.stopPropagation),L.DomEvent.addListener(this.options.styleEditorDiv,"mouseenter",this.disableLeafletActions,this),L.DomEvent.addListener(this.options.styleEditorDiv,"mouseleave",this.enableLeafletActions,this)},addLeafletDrawEvents:function(){this.options.openOnLeafletDraw&&L.Control.Draw&&this.options.map.on("draw:created",function(t){this.initChangeStyle({target:t.layer})},this)},addButtons:function(){var t=L.DomUtil.create("button","leaflet-styleeditor-button styleeditor-nextBtn",this.options.styleEditorHeader);t.title=this.options.strings.tooltipNext,L.DomEvent.addListener(t,"click",function(t){this.hideEditor(),L.DomUtil.hasClass(this.options.controlUI,"enabled")&&this.createTooltip(),t.stopPropagation()},this)},clickHandler:function(t){this.options.enabled=!this.options.enabled,this.options.enabled?this.enable():(L.DomUtil.removeClass(this.options.controlUI,"enabled"),this.disable())},disableLeafletActions:function(){var t=this.options.map;t.dragging.disable(),t.touchZoom.disable(),t.doubleClickZoom.disable(),t.scrollWheelZoom.disable(),t.boxZoom.disable(),t.keyboard.disable()},enableLeafletActions:function(){var t=this.options.map;t.dragging.enable(),t.touchZoom.enable(),t.doubleClickZoom.enable(),t.scrollWheelZoom.enable(),t.boxZoom.enable(),t.keyboard.enable()},enable:function(){L.DomUtil.addClass(this.options.controlUI,"enabled"),this.options.map.eachLayer(this.addEditClickEvents,this),this.createTooltip()},disable:function(){this.options.editLayers.forEach(this.removeEditClickEvents,this),this.options.editLayers=[],this.options.layerGroups=[],this.hideEditor(),this.removeTooltip()},addEditClickEvents:function(t){if(this.options.useGrouping&&t instanceof L.LayerGroup)this.options.layerGroups.push(t);else if(t instanceof L.Marker||t instanceof L.Path){var e=t.on("click",this.initChangeStyle,this);this.options.editLayers.push(e)}},removeEditClickEvents:function(t){t.off("click",this.initChangeStyle,this)},hideEditor:function(){L.DomUtil.removeClass(this.options.styleEditorDiv,"editor-enabled")},showEditor:function(){var t=this.options.styleEditorDiv;L.DomUtil.hasClass(t,"editor-enabled")||L.DomUtil.addClass(t,"editor-enabled")},initChangeStyle:function(t){this.options.currentElement=this.options.useGrouping?this.getMatchingElement(t):t,this.showEditor(),this.removeTooltip(),t.target instanceof L.Marker?this.showMarkerForm():this.showGeometryForm()},showGeometryForm:function(){this.options.styleForm.showGeometryForm()},showMarkerForm:function(){this.options.styleForm.showMarkerForm()},createTooltip:function(){this.options.showTooltip&&(this.options.tooltipWrapper||(this.options.tooltipWrapper=L.DomUtil.create("div","leaflet-styleeditor-tooltip-wrapper",this.options.map.getContainer())),this.options.tooltip||(this.options.tooltip=L.DomUtil.create("div","leaflet-styleeditor-tooltip",this.options.tooltipWrapper)),this.options.tooltip.innerHTML=this.options.strings.tooltip)},getMatchingElement:function(t){for(var e=null,o=t.target,i=0;i Date: Thu, 7 Sep 2017 16:38:34 +0200 Subject: [PATCH 4/5] respect settings * allow definition of defaultColor * allow definition of defaultMarker * allow definition of allowed markers --- src/javascript/Control.js | 4 +- src/javascript/Form/MarkerForm.js | 2 +- src/javascript/Marker/Marker.js | 36 +++++++++++++---- src/javascript/Util.js | 67 +++++++++++++++++++++++++------ 4 files changed, 87 insertions(+), 22 deletions(-) diff --git a/src/javascript/Control.js b/src/javascript/Control.js index 6b4553d..d5596e9 100644 --- a/src/javascript/Control.js +++ b/src/javascript/Control.js @@ -5,7 +5,7 @@ L.Control.StyleEditor = L.Control.extend({ colorRamp: ['#1abc9c', '#2ecc71', '#3498db', '#9b59b6', '#34495e', '#16a085', '#27ae60', '#2980b9', '#8e44ad', '#2c3e50', '#f1c40f', '#e67e22', '#e74c3c', '#ecf0f1', '#95a5a6', '#f39c12', '#d35400', '#c0392b', '#bdc3c7', '#7f8c8d'], - defaultColor: 'f39c12', + defaultColor: null, currentElement: null, markerType: L.StyleEditor.marker.DefaultMarker, geometryForm: L.StyleEditor.forms.GeometryForm, @@ -17,6 +17,8 @@ L.Control.StyleEditor = L.Control.extend({ tooltip: 'Click on the element you want to style', tooltipNext: 'Choose another element you want to style' }, + markers: null, + defaultMarker: null, useGrouping: true }, diff --git a/src/javascript/Form/MarkerForm.js b/src/javascript/Form/MarkerForm.js index ab51bd1..a556ef4 100644 --- a/src/javascript/Form/MarkerForm.js +++ b/src/javascript/Form/MarkerForm.js @@ -10,7 +10,7 @@ L.StyleEditor.forms.MarkerForm = L.StyleEditor.forms.Form.extend({ /** before showing the MarkerForm update currently used MarkerIcon */ preShow: function () { - Object.assign(this.options.styleEditorOptions.markerType.options.iconOptions, + Object.assign(this.options.styleEditorOptions.markerType.getIconOptions(), this.options.styleEditorOptions.util.getCurrentElement().options.icon.options); } }); diff --git a/src/javascript/Marker/Marker.js b/src/javascript/Marker/Marker.js index 7e42034..e3760da 100644 --- a/src/javascript/Marker/Marker.js +++ b/src/javascript/Marker/Marker.js @@ -8,16 +8,11 @@ L.StyleEditor.marker.Marker = L.Class.extend({ /** set standard icon */ initialize: function(options) { L.setOptions(this, options); - this.options.iconOptions = { - iconSize: [20, 50], - iconColor: 'rgb(41, 128, 185)', - icon: 'square' - }; }, /** create new Marker and show it */ setNewMarker: function() { - var iconOptions = this._ensureMarkerIcon(this.options.iconOptions); + var iconOptions = this.getIconOptions(); if (iconOptions.iconSize && iconOptions.icon && iconOptions.iconColor) { var newIcon = this._createMarkerIcon(iconOptions); @@ -28,7 +23,7 @@ L.StyleEditor.marker.Marker = L.Class.extend({ /** set styling options */ setStyle: function (styleOption, value) { - var iconOptions = this._ensureMarkerIcon(this.options.iconOptions); + var iconOptions = this.getIconOptions(); if(iconOptions[styleOption] != value) { iconOptions[styleOption] = value; this.setNewMarker(); @@ -40,8 +35,33 @@ L.StyleEditor.marker.Marker = L.Class.extend({ this.createSelectHTML(parentUiElement, iconOptions, icon); }, + getIconOptions: function() { + if (!this.options.iconOptions) { + var color = this.options.styleEditorOptions.defaultColor; + if (color == null) { + color = this.options.defaultColor; + } + if (color == null && this.options.colorRamp != null) { + color = this.options.colorRamp[0]; + } + if (color == null) { + color = this.options.styleEditorOptions.colorRamp[0]; + } + + color = this.options.styleEditorOptions.util.rgbToHex(color); + + this.options.iconOptions = { + iconSize: [20, 50], + iconColor: color, + icon: this.options.styleEditorOptions.util.getDefaultMarkerForColor(color) + }; + } + + return this._ensureMarkerIcon(this.options.iconOptions); + }, + _createMarkerIcon: function(iconOptions) { - iconOptions = this._ensureMarkerIcon(iconOptions); + iconOptions = this.getIconOptions(iconOptions); return this.createMarkerIcon(iconOptions); }, diff --git a/src/javascript/Util.js b/src/javascript/Util.js index d5caba2..5ef1e66 100644 --- a/src/javascript/Util.js +++ b/src/javascript/Util.js @@ -28,6 +28,9 @@ L.StyleEditor.Util = L.Class.extend({ rgbToHex: function(rgb, no_hash) { if (!rgb) { rgb = this.options.styleEditorOptions.defaultColor; + if(rgb.indexOf('#') != 0) { + rgb = '#'+rgb; + } } if (rgb.indexOf('#') == 0) { @@ -37,6 +40,10 @@ L.StyleEditor.Util = L.Class.extend({ return rgb; } + if (rgb.indexOf('(') < 0) { + return '#' + rgb; + } + var without_hash = ''; rgb = rgb.substring(4).replace(')', '').split(','); without_hash = this._componentToHex(parseInt(rgb[0], 10)) + this._componentToHex(parseInt(rgb[1], 10)) + @@ -105,36 +112,72 @@ L.StyleEditor.Util = L.Class.extend({ /** get the markers for a specific color **/ getMarkersForColor: function(color) { + color = this.rgbToHex(color); + var markers = this.options.styleEditorOptions.markerType.options.markers; + var controlMarkers = this.options.styleEditorOptions.markers; // if only an array of markers is given return it - if (Array.isArray(markers)) { - return markers; + if (!Array.isArray(markers)) { + + // if color is specified return specific markers + if (Object.keys(markers).includes(color)) { + markers = markers[color]; + } else { + markers = markers['default']; + } } + if (controlMarkers != null) { + if(!Array.isArray(controlMarkers)) { + var keys = Object.keys(controlMarkers); + if(keys.includes(color)) { + controlMarkers = controlMarkers[color]; + } else if (keys.includes('default')) { + controlMarkers = controlMarkers['default']; + } else { + controlMarkers = markers; + } + } - // if color is specified return specific markers - color = this.rgbToHex(color); - if (Object.keys(markers).includes(color)) { - return markers[color]; + return markers.filter((n) => controlMarkers.includes(n)) } - // return default markers - return markers.default; + return markers; }, /** get default marker for specific color **/ getDefaultMarkerForColor: function(color) { color = this.rgbToHex(color); - var defaultMarker = this.options.styleEditorOptions.markerType.options.defaultMarker; + var markers = this.getMarkersForColor(color); + var defMarkers = []; + + var defaultMarker = this.options.styleEditorOptions.defaultMarker; + if (defaultMarker != null) { + if (typeof defaultMarker === 'string') { + defMarkers.push(defaultMarker); + } + if (Object.keys(defaultMarker).includes(color)) { + defMarkers.push(defaultMarker[color]); + } + + } + + defaultMarker = this.options.styleEditorOptions.markerType.options.defaultMarker; if (defaultMarker != undefined) { - if (typeof myVar === 'string' && markers.includes(defaultMarker)) { - return defaultMarker; + if (typeof defaultMarker === 'string') { + defMarkers.push(defaultMarker); } if (Object.keys(defaultMarker).includes(color)) { - return defaultMarker[color]; + defMarkers.push(defaultMarker[color]); } } + + defMarkers.filter((n) => markers.includes(n)); + if (defMarkers.length > 0) { + return defMarkers[0]; + } + return markers[0]; } From 7a050501934d7cc56465992b1e1f17e367a71449 Mon Sep 17 00:00:00 2001 From: Fup Duck Date: Thu, 7 Sep 2017 17:00:49 +0200 Subject: [PATCH 5/5] update min js --- dist/javascript/Leaflet.StyleEditor.min.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/javascript/Leaflet.StyleEditor.min.js b/dist/javascript/Leaflet.StyleEditor.min.js index 7b48e95..f191f65 100644 --- a/dist/javascript/Leaflet.StyleEditor.min.js +++ b/dist/javascript/Leaflet.StyleEditor.min.js @@ -1 +1 @@ -!function(t,e){"function"==typeof define&&define.amd?define(["leaflet"],t):"object"==typeof exports&&(module.exports=t(require("leaflet"))),void 0!==e&&e.L&&(e.L.StyleEditor=t(L))}(function(t){return{marker:{},forms:{},formElements:{}}},window),L.StyleEditor.Util=L.Class.extend({initialize:function(t){t&&L.setOptions(this,t)},fireChangeEvent:function(t){this.options.styleEditorOptions.map.fireEvent("styleeditor:changed",t)},hideElement:function(t){t&&L.DomUtil.addClass(t,"leaflet-styleeditor-hidden")},rgbToHex:function(t,e){if(t||(t=this.options.styleEditorOptions.defaultColor),0==t.indexOf("#"))return e&&t.replace("#",""),t;var o="";return t=t.substring(4).replace(")","").split(","),o=this._componentToHex(parseInt(t[0],10))+this._componentToHex(parseInt(t[1],10))+this._componentToHex(parseInt(t[2],10)),e?o:"#"+o},getCurrentElement:function(){return this.options.styleEditorOptions.currentElement?this.options.styleEditorOptions.currentElement.target:null},setCurrentElement:function(t){this.options.styleEditorOptions.currentElement.target=t},fillCurrentElement:function(){return this.getCurrentElement().options.fill},getStyle:function(t){var e=this.getCurrentElement().options[t];return e||null},setStyle:function(t,e){var o=this.getCurrentElement();if(o instanceof L.Marker)this.options.styleEditorOptions.markerType.setStyle(t,e);else{var i={};i[t]=e,o.setStyle(i)}this.fireChangeEvent(o)},showElement:function(t){t&&L.DomUtil.removeClass(t,"leaflet-styleeditor-hidden")},_componentToHex:function(t){var e=t.toString(16);return 1===e.length?"0"+e:e},getMarkersForColor:function(t){var e=this.options.styleEditorOptions.markerType.options.markers;return Array.isArray(e)?e:(t=this.rgbToHex(t),Object.keys(e).includes(t)?e[t]:e.default)},getDefaultMarkerForColor:function(t){t=this.rgbToHex(t);var e=this.options.styleEditorOptions.markerType.options.defaultMarker,o=this.getMarkersForColor(t);if(void 0!=e){if("string"==typeof myVar&&o.includes(e))return e;if(Object.keys(e).includes(t))return e[t]}return o[0]}}),L.StyleEditor.formElements.FormElement=L.Class.extend({initialize:function(t){t&&L.setOptions(this,t),this.options.styleOption&&(this.options.title=this.options.styleOption.charAt(0).toUpperCase()+this.options.styleOption.slice(1))},create:function(t){this.options.uiElement=L.DomUtil.create("div","leaflet-styleeditor-uiElement",t);this.createTitle(),this.createContent()},createTitle:function(){L.DomUtil.create("label","leaflet-styleeditor-label",this.options.uiElement).innerHTML=this.options.title+":"},createContent:function(){},show:function(){this.style(),this.showForm()},showForm:function(){this.options.styleEditorOptions.util.showElement(this.options.uiElement)},hide:function(){this.options.styleEditorOptions.util.hideElement(this.options.uiElement)},style:function(){},lostFocus:function(){},setStyle:function(t){var e=this.options.styleEditorOptions.util.getCurrentElement(),o=[e];e instanceof L.LayerGroup&&(o=Object.values(e._layers));for(var i=0;i=30?t[0]>=35?"l":"m":"s"},options:{markers:["circle-stroked","circle","square-stroked","square","triangle-stroked","triangle","star-stroked","star","cross","marker-stroked","marker","religious-jewish","religious-christian","religious-muslim","cemetery","rocket","airport","heliport","rail","rail-metro","rail-light","bus","fuel","parking","parking-garage","airfield","roadblock","ferry","harbor","bicycle","park","park2","museum","lodging","monument","zoo","garden","campsite","theatre","art-gallery","pitch","soccer","america-football","tennis","basketball","baseball","golf","swimming","cricket","skiing","school","college","library","post","fire-station","town-hall","police","prison","embassy","beer","restaurant","cafe","shop","fast-food","bar","bank","grocery","cinema","pharmacy","hospital","danger","industrial","warehouse","commercial","building","place-of-worship","alcohol-shop","logging","oil-well","slaughterhouse","dam","water","wetland","disability","telephone","emergency-telephone","toilets","waste-basket","music","land-use","city","town","village","farm","bakery","dog-park","lighthouse","clothing-store","polling-place","playground","entrance","heart","london-underground","minefield","rail-underground","rail-above","camera","laundry","car","suitcase","hairdresser","chemist","mobilephone","scooter"]}}),L.StyleEditor.marker.GlyphiconMarker=L.StyleEditor.marker.Marker.extend({getMarkerHtml:function(t,e,o){var i=this._getMarkerUrl(t,e);return'
'},createMarkerIcon:function(t){var e=t.iconSize;return new L.divIcon({className:"leaflet-styleeditor-glyphicon-marker-wrapper",html:this.getMarkerHtml(e,t.iconColor,t.icon),icon:t.icon,iconColor:t.iconColor,iconSize:e,iconAnchor:[e[0]/2,e[1]/2],popupAnchor:[0,-e[1]/2]})},setStyle:function(t,e){"icon"!=t&&(t="icon"+t.charAt(0).toUpperCase()+t.slice(1));var o=this.options.iconOptions;o[t]!=e&&(o[t]=e,this.setNewMarker())},createSelectHTML:function(t,e,o){t.innerHTML=this.getMarkerHtml("s",e.iconColor,o)},_size:function(t){return t[0]>=30?t[0]>=35?"l":"m":"s"},_getMarkerUrlForStyle:function(t){return this._getMarkerUrl(t.iconSize,t.iconColor,t.icon)},_getMarkerUrl:function(t,e,o){return"http://api.tiles.mapbox.com/v3/marker/pin-"+(t=this._size(t))+"+"+(e=0==e.indexOf("#")?e.replace("#",""):this.options.styleEditorOptions.util.rgbToHex(e,!0))+".png"},options:{markers:["glyphicon-plus","glyphicon-asterisk","glyphicon-plus","glyphicon-euro","glyphicon-minus","glyphicon-cloud","glyphicon-envelope","glyphicon-pencil","glyphicon-glass","glyphicon-music","glyphicon-search","glyphicon-heart","glyphicon-star","glyphicon-star-empty","glyphicon-user","glyphicon-film","glyphicon-th-large","glyphicon-th","glyphicon-th-list","glyphicon-ok","glyphicon-remove","glyphicon-zoom-in","glyphicon-zoom-out","glyphicon-off","glyphicon-signal","glyphicon-cog","glyphicon-trash","glyphicon-home","glyphicon-file","glyphicon-time","glyphicon-road","glyphicon-download-alt","glyphicon-download","glyphicon-upload","glyphicon-inbox","glyphicon-play-circle","glyphicon-repeat","glyphicon-refresh","glyphicon-list-alt","glyphicon-lock","glyphicon-flag","glyphicon-headphones","glyphicon-volume-off","glyphicon-volume-down","glyphicon-volume-up","glyphicon-qrcode","glyphicon-barcode","glyphicon-tag","glyphicon-tags","glyphicon-book","glyphicon-bookmark","glyphicon-print","glyphicon-camera","glyphicon-font","glyphicon-bold","glyphicon-italic","glyphicon-text-height","glyphicon-text-width","glyphicon-align-left","glyphicon-align-center","glyphicon-align-right","glyphicon-align-justify","glyphicon-list","glyphicon-indent-left","glyphicon-indent-right","glyphicon-facetime-video","glyphicon-picture","glyphicon-map-marker","glyphicon-adjust","glyphicon-tint","glyphicon-edit","glyphicon-share","glyphicon-check","glyphicon-move","glyphicon-chevron-right","glyphicon-plus-sign","glyphicon-minus-sign","glyphicon-remove-sign","glyphicon-ok-sign","glyphicon-question-sign","glyphicon-info-sign","glyphicon-screenshot","glyphicon-remove-circle","glyphicon-ok-circle","glyphicon-ban-circle","glyphicon-arrow-left","glyphicon-arrow-right","glyphicon-arrow-up","glyphicon-arrow-down","glyphicon-share-alt","glyphicon-resize-full","glyphicon-resize-small","glyphicon-exclamation-sign","glyphicon-gift","glyphicon-leaf","glyphicon-fire","glyphicon-eye-open","glyphicon-eye-close","glyphicon-warning-sign","glyphicon-plane","glyphicon-calendar","glyphicon-random","glyphicon-comment","glyphicon-magnet","glyphicon-chevron-up","glyphicon-chevron-down","glyphicon-retweet","glyphicon-shopping-cart","glyphicon-bullhorn","glyphicon-bell","glyphicon-certificate","glyphicon-thumbs-up","glyphicon-thumbs-down","glyphicon-hand-right","glyphicon-hand-left","glyphicon-hand-up","glyphicon-hand-down","glyphicon-circle-arrow-right","glyphicon-circle-arrow-left","glyphicon-circle-arrow-up","glyphicon-circle-arrow-down","glyphicon-globe","glyphicon-wrench","glyphicon-tasks","glyphicon-filter","glyphicon-briefcase","glyphicon-fullscreen","glyphicon-dashboard","glyphicon-paperclip","glyphicon-heart-empty","glyphicon-link","glyphicon-phone","glyphicon-pushpin","glyphicon-usd"]}}),L.StyleForm=L.Class.extend({initialize:function(t){L.setOptions(this,t),this.createMarkerForm(),this.createGeometryForm(),this.addDOMEvents()},addDOMEvents:function(){L.DomEvent.addListener(this.options.styleEditorOptions.map,"click",this.lostFocus,this),L.DomEvent.addListener(this.options.styleEditorDiv,"click",this.lostFocus,this)},clearForm:function(){this.options.styleEditorOptions.markerForm.hide(),this.options.styleEditorOptions.geometryForm.hide()},createMarkerForm:function(){var t=L.DomUtil.create("div","leaflet-styleeditor-interior-marker",this.options.styleEditorInterior);this.options.styleEditorOptions.markerForm.create(t)},createGeometryForm:function(){var t=L.DomUtil.create("div","leaflet-styleeditor-interior-geometry",this.options.styleEditorInterior);this.options.styleEditorOptions.geometryForm.create(t)},showMarkerForm:function(){this.clearForm(),this.options.styleEditorOptions.markerForm.show()},showGeometryForm:function(){this.clearForm(),this.options.styleEditorOptions.geometryForm.show()},fireChangeEvent:function(t){this.options.styleEditorOptions.map.fireEvent("styleeditor:changed",t)},lostFocus:function(t){for(var e=t.target,o=0;o<10&&e;o++){if(e.className&&L.DomUtil.hasClass(e,"leaflet-styleeditor-interior"))return;e=e.parentNode}this.options.styleEditorOptions.markerForm.lostFocus(),this.options.styleEditorOptions.geometryForm.lostFocus()}}),L.Control.StyleEditor=L.Control.extend({options:{position:"topleft",enabled:!1,colorRamp:["#1abc9c","#2ecc71","#3498db","#9b59b6","#34495e","#16a085","#27ae60","#2980b9","#8e44ad","#2c3e50","#f1c40f","#e67e22","#e74c3c","#ecf0f1","#95a5a6","#f39c12","#d35400","#c0392b","#bdc3c7","#7f8c8d"],defaultColor:"f39c12",currentElement:null,markerType:L.StyleEditor.marker.DefaultMarker,geometryForm:L.StyleEditor.forms.GeometryForm,editLayers:[],layerGroups:[],openOnLeafletDraw:!0,showTooltip:!0,strings:{tooltip:"Click on the element you want to style",tooltipNext:"Choose another element you want to style"},useGrouping:!0},initialize:function(t){t&&L.setOptions(this,t),this.options.util=new L.StyleEditor.Util({styleEditorOptions:this.options}),this.options.markerType=new this.options.markerType({styleEditorOptions:this.options}),this.options.markerForm=new this.options.markerType.markerForm({styleEditorOptions:this.options}),this.options.geometryForm=new this.options.geometryForm({styleEditorOptions:this.options})},onAdd:function(t){return this.options.map=t,this.createUi()},createUi:function(){var t=this.options.controlDiv=L.DomUtil.create("div","leaflet-control-styleeditor leaflet-bar");(this.options.controlUI=L.DomUtil.create("a","leaflet-control-styleeditor-interior",t)).title="Style Editor";var e=this.options.styleEditorDiv=L.DomUtil.create("div","leaflet-styleeditor",this.options.map._container);this.options.styleEditorHeader=L.DomUtil.create("div","leaflet-styleeditor-header",e);var o=L.DomUtil.create("div","leaflet-styleeditor-interior",e);return this.addDomEvents(),this.addLeafletDrawEvents(),this.addButtons(),this.options.styleForm=new L.StyleForm({styleEditorDiv:e,styleEditorInterior:o,styleEditorOptions:this.options}),t},addDomEvents:function(){L.DomEvent.addListener(this.options.controlDiv,"click",function(t){this.clickHandler(t),t.stopPropagation()},this),L.DomEvent.addListener(this.options.controlDiv,"dblclick",function(t){t.stopPropagation()},this),L.DomEvent.addListener(this.options.styleEditorDiv,"click",L.DomEvent.stopPropagation),L.DomEvent.addListener(this.options.styleEditorDiv,"mouseenter",this.disableLeafletActions,this),L.DomEvent.addListener(this.options.styleEditorDiv,"mouseleave",this.enableLeafletActions,this)},addLeafletDrawEvents:function(){this.options.openOnLeafletDraw&&L.Control.Draw&&this.options.map.on("draw:created",function(t){this.initChangeStyle({target:t.layer})},this)},addButtons:function(){var t=L.DomUtil.create("button","leaflet-styleeditor-button styleeditor-nextBtn",this.options.styleEditorHeader);t.title=this.options.strings.tooltipNext,L.DomEvent.addListener(t,"click",function(t){this.hideEditor(),L.DomUtil.hasClass(this.options.controlUI,"enabled")&&this.createTooltip(),t.stopPropagation()},this)},clickHandler:function(t){this.options.enabled=!this.options.enabled,this.options.enabled?this.enable():(L.DomUtil.removeClass(this.options.controlUI,"enabled"),this.disable())},disableLeafletActions:function(){var t=this.options.map;t.dragging.disable(),t.touchZoom.disable(),t.doubleClickZoom.disable(),t.scrollWheelZoom.disable(),t.boxZoom.disable(),t.keyboard.disable()},enableLeafletActions:function(){var t=this.options.map;t.dragging.enable(),t.touchZoom.enable(),t.doubleClickZoom.enable(),t.scrollWheelZoom.enable(),t.boxZoom.enable(),t.keyboard.enable()},enable:function(){L.DomUtil.addClass(this.options.controlUI,"enabled"),this.options.map.eachLayer(this.addEditClickEvents,this),this.createTooltip()},disable:function(){this.options.editLayers.forEach(this.removeEditClickEvents,this),this.options.editLayers=[],this.options.layerGroups=[],this.hideEditor(),this.removeTooltip()},addEditClickEvents:function(t){if(this.options.useGrouping&&t instanceof L.LayerGroup)this.options.layerGroups.push(t);else if(t instanceof L.Marker||t instanceof L.Path){var e=t.on("click",this.initChangeStyle,this);this.options.editLayers.push(e)}},removeEditClickEvents:function(t){t.off("click",this.initChangeStyle,this)},hideEditor:function(){L.DomUtil.removeClass(this.options.styleEditorDiv,"editor-enabled")},showEditor:function(){var t=this.options.styleEditorDiv;L.DomUtil.hasClass(t,"editor-enabled")||L.DomUtil.addClass(t,"editor-enabled")},initChangeStyle:function(t){this.options.currentElement=this.options.useGrouping?this.getMatchingElement(t):t,this.showEditor(),this.removeTooltip(),t.target instanceof L.Marker?this.showMarkerForm():this.showGeometryForm()},showGeometryForm:function(){this.options.styleForm.showGeometryForm()},showMarkerForm:function(){this.options.styleForm.showMarkerForm()},createTooltip:function(){this.options.showTooltip&&(this.options.tooltipWrapper||(this.options.tooltipWrapper=L.DomUtil.create("div","leaflet-styleeditor-tooltip-wrapper",this.options.map.getContainer())),this.options.tooltip||(this.options.tooltip=L.DomUtil.create("div","leaflet-styleeditor-tooltip",this.options.tooltipWrapper)),this.options.tooltip.innerHTML=this.options.strings.tooltip)},getMatchingElement:function(t){for(var e=null,o=t.target,i=0;io.includes(t))}return e},getDefaultMarkerForColor:function(t){t=this.rgbToHex(t);var e=this.getMarkersForColor(t),o=[],i=this.options.styleEditorOptions.defaultMarker;return null!=i&&("string"==typeof i&&o.push(i),Object.keys(i).includes(t)&&o.push(i[t])),void 0!=(i=this.options.styleEditorOptions.markerType.options.defaultMarker)&&("string"==typeof i&&o.push(i),Object.keys(i).includes(t)&&o.push(i[t])),o.filter(t=>e.includes(t)),o.length>0?o[0]:e[0]}}),L.StyleEditor.formElements.FormElement=L.Class.extend({initialize:function(t){t&&L.setOptions(this,t),this.options.styleOption&&(this.options.title=this.options.styleOption.charAt(0).toUpperCase()+this.options.styleOption.slice(1))},create:function(t){this.options.uiElement=L.DomUtil.create("div","leaflet-styleeditor-uiElement",t);this.createTitle(),this.createContent()},createTitle:function(){L.DomUtil.create("label","leaflet-styleeditor-label",this.options.uiElement).innerHTML=this.options.title+":"},createContent:function(){},show:function(){this.style(),this.showForm()},showForm:function(){this.options.styleEditorOptions.util.showElement(this.options.uiElement)},hide:function(){this.options.styleEditorOptions.util.hideElement(this.options.uiElement)},style:function(){},lostFocus:function(){},setStyle:function(t){var e=this.options.styleEditorOptions.util.getCurrentElement(),o=[e];e instanceof L.LayerGroup&&(o=Object.values(e._layers));for(var i=0;i=30?t[0]>=35?"l":"m":"s"},options:{markers:["circle-stroked","circle","square-stroked","square","triangle-stroked","triangle","star-stroked","star","cross","marker-stroked","marker","religious-jewish","religious-christian","religious-muslim","cemetery","rocket","airport","heliport","rail","rail-metro","rail-light","bus","fuel","parking","parking-garage","airfield","roadblock","ferry","harbor","bicycle","park","park2","museum","lodging","monument","zoo","garden","campsite","theatre","art-gallery","pitch","soccer","america-football","tennis","basketball","baseball","golf","swimming","cricket","skiing","school","college","library","post","fire-station","town-hall","police","prison","embassy","beer","restaurant","cafe","shop","fast-food","bar","bank","grocery","cinema","pharmacy","hospital","danger","industrial","warehouse","commercial","building","place-of-worship","alcohol-shop","logging","oil-well","slaughterhouse","dam","water","wetland","disability","telephone","emergency-telephone","toilets","waste-basket","music","land-use","city","town","village","farm","bakery","dog-park","lighthouse","clothing-store","polling-place","playground","entrance","heart","london-underground","minefield","rail-underground","rail-above","camera","laundry","car","suitcase","hairdresser","chemist","mobilephone","scooter"]}}),L.StyleEditor.marker.GlyphiconMarker=L.StyleEditor.marker.Marker.extend({getMarkerHtml:function(t,e,o){var i=this._getMarkerUrl(t,e);return'
'},createMarkerIcon:function(t){var e=t.iconSize;return new L.divIcon({className:"leaflet-styleeditor-glyphicon-marker-wrapper",html:this.getMarkerHtml(e,t.iconColor,t.icon),icon:t.icon,iconColor:t.iconColor,iconSize:e,iconAnchor:[e[0]/2,e[1]/2],popupAnchor:[0,-e[1]/2]})},setStyle:function(t,e){"icon"!=t&&(t="icon"+t.charAt(0).toUpperCase()+t.slice(1));var o=this.options.iconOptions;o[t]!=e&&(o[t]=e,this.setNewMarker())},createSelectHTML:function(t,e,o){t.innerHTML=this.getMarkerHtml("s",e.iconColor,o)},_size:function(t){return t[0]>=30?t[0]>=35?"l":"m":"s"},_getMarkerUrlForStyle:function(t){return this._getMarkerUrl(t.iconSize,t.iconColor,t.icon)},_getMarkerUrl:function(t,e,o){return"http://api.tiles.mapbox.com/v3/marker/pin-"+(t=this._size(t))+"+"+(e=0==e.indexOf("#")?e.replace("#",""):this.options.styleEditorOptions.util.rgbToHex(e,!0))+".png"},options:{markers:["glyphicon-plus","glyphicon-asterisk","glyphicon-plus","glyphicon-euro","glyphicon-minus","glyphicon-cloud","glyphicon-envelope","glyphicon-pencil","glyphicon-glass","glyphicon-music","glyphicon-search","glyphicon-heart","glyphicon-star","glyphicon-star-empty","glyphicon-user","glyphicon-film","glyphicon-th-large","glyphicon-th","glyphicon-th-list","glyphicon-ok","glyphicon-remove","glyphicon-zoom-in","glyphicon-zoom-out","glyphicon-off","glyphicon-signal","glyphicon-cog","glyphicon-trash","glyphicon-home","glyphicon-file","glyphicon-time","glyphicon-road","glyphicon-download-alt","glyphicon-download","glyphicon-upload","glyphicon-inbox","glyphicon-play-circle","glyphicon-repeat","glyphicon-refresh","glyphicon-list-alt","glyphicon-lock","glyphicon-flag","glyphicon-headphones","glyphicon-volume-off","glyphicon-volume-down","glyphicon-volume-up","glyphicon-qrcode","glyphicon-barcode","glyphicon-tag","glyphicon-tags","glyphicon-book","glyphicon-bookmark","glyphicon-print","glyphicon-camera","glyphicon-font","glyphicon-bold","glyphicon-italic","glyphicon-text-height","glyphicon-text-width","glyphicon-align-left","glyphicon-align-center","glyphicon-align-right","glyphicon-align-justify","glyphicon-list","glyphicon-indent-left","glyphicon-indent-right","glyphicon-facetime-video","glyphicon-picture","glyphicon-map-marker","glyphicon-adjust","glyphicon-tint","glyphicon-edit","glyphicon-share","glyphicon-check","glyphicon-move","glyphicon-chevron-right","glyphicon-plus-sign","glyphicon-minus-sign","glyphicon-remove-sign","glyphicon-ok-sign","glyphicon-question-sign","glyphicon-info-sign","glyphicon-screenshot","glyphicon-remove-circle","glyphicon-ok-circle","glyphicon-ban-circle","glyphicon-arrow-left","glyphicon-arrow-right","glyphicon-arrow-up","glyphicon-arrow-down","glyphicon-share-alt","glyphicon-resize-full","glyphicon-resize-small","glyphicon-exclamation-sign","glyphicon-gift","glyphicon-leaf","glyphicon-fire","glyphicon-eye-open","glyphicon-eye-close","glyphicon-warning-sign","glyphicon-plane","glyphicon-calendar","glyphicon-random","glyphicon-comment","glyphicon-magnet","glyphicon-chevron-up","glyphicon-chevron-down","glyphicon-retweet","glyphicon-shopping-cart","glyphicon-bullhorn","glyphicon-bell","glyphicon-certificate","glyphicon-thumbs-up","glyphicon-thumbs-down","glyphicon-hand-right","glyphicon-hand-left","glyphicon-hand-up","glyphicon-hand-down","glyphicon-circle-arrow-right","glyphicon-circle-arrow-left","glyphicon-circle-arrow-up","glyphicon-circle-arrow-down","glyphicon-globe","glyphicon-wrench","glyphicon-tasks","glyphicon-filter","glyphicon-briefcase","glyphicon-fullscreen","glyphicon-dashboard","glyphicon-paperclip","glyphicon-heart-empty","glyphicon-link","glyphicon-phone","glyphicon-pushpin","glyphicon-usd"]}}),L.StyleForm=L.Class.extend({initialize:function(t){L.setOptions(this,t),this.createMarkerForm(),this.createGeometryForm(),this.addDOMEvents()},addDOMEvents:function(){L.DomEvent.addListener(this.options.styleEditorOptions.map,"click",this.lostFocus,this),L.DomEvent.addListener(this.options.styleEditorDiv,"click",this.lostFocus,this)},clearForm:function(){this.options.styleEditorOptions.markerForm.hide(),this.options.styleEditorOptions.geometryForm.hide()},createMarkerForm:function(){var t=L.DomUtil.create("div","leaflet-styleeditor-interior-marker",this.options.styleEditorInterior);this.options.styleEditorOptions.markerForm.create(t)},createGeometryForm:function(){var t=L.DomUtil.create("div","leaflet-styleeditor-interior-geometry",this.options.styleEditorInterior);this.options.styleEditorOptions.geometryForm.create(t)},showMarkerForm:function(){this.clearForm(),this.options.styleEditorOptions.markerForm.show()},showGeometryForm:function(){this.clearForm(),this.options.styleEditorOptions.geometryForm.show()},fireChangeEvent:function(t){this.options.styleEditorOptions.map.fireEvent("styleeditor:changed",t)},lostFocus:function(t){for(var e=t.target,o=0;o<10&&e;o++){if(e.className&&L.DomUtil.hasClass(e,"leaflet-styleeditor-interior"))return;e=e.parentNode}this.options.styleEditorOptions.markerForm.lostFocus(),this.options.styleEditorOptions.geometryForm.lostFocus()}}),L.Control.StyleEditor=L.Control.extend({options:{position:"topleft",enabled:!1,colorRamp:["#1abc9c","#2ecc71","#3498db","#9b59b6","#34495e","#16a085","#27ae60","#2980b9","#8e44ad","#2c3e50","#f1c40f","#e67e22","#e74c3c","#ecf0f1","#95a5a6","#f39c12","#d35400","#c0392b","#bdc3c7","#7f8c8d"],defaultColor:null,currentElement:null,markerType:L.StyleEditor.marker.DefaultMarker,geometryForm:L.StyleEditor.forms.GeometryForm,editLayers:[],layerGroups:[],openOnLeafletDraw:!0,showTooltip:!0,strings:{tooltip:"Click on the element you want to style",tooltipNext:"Choose another element you want to style"},markers:null,defaultMarker:null,useGrouping:!0},initialize:function(t){t&&L.setOptions(this,t),this.options.util=new L.StyleEditor.Util({styleEditorOptions:this.options}),this.options.markerType=new this.options.markerType({styleEditorOptions:this.options}),this.options.markerForm=new this.options.markerType.markerForm({styleEditorOptions:this.options}),this.options.geometryForm=new this.options.geometryForm({styleEditorOptions:this.options})},onAdd:function(t){return this.options.map=t,this.createUi()},createUi:function(){var t=this.options.controlDiv=L.DomUtil.create("div","leaflet-control-styleeditor leaflet-bar");(this.options.controlUI=L.DomUtil.create("a","leaflet-control-styleeditor-interior",t)).title="Style Editor";var e=this.options.styleEditorDiv=L.DomUtil.create("div","leaflet-styleeditor",this.options.map._container);this.options.styleEditorHeader=L.DomUtil.create("div","leaflet-styleeditor-header",e);var o=L.DomUtil.create("div","leaflet-styleeditor-interior",e);return this.addDomEvents(),this.addLeafletDrawEvents(),this.addButtons(),this.options.styleForm=new L.StyleForm({styleEditorDiv:e,styleEditorInterior:o,styleEditorOptions:this.options}),t},addDomEvents:function(){L.DomEvent.addListener(this.options.controlDiv,"click",function(t){this.clickHandler(t),t.stopPropagation()},this),L.DomEvent.addListener(this.options.controlDiv,"dblclick",function(t){t.stopPropagation()},this),L.DomEvent.addListener(this.options.styleEditorDiv,"click",L.DomEvent.stopPropagation),L.DomEvent.addListener(this.options.styleEditorDiv,"mouseenter",this.disableLeafletActions,this),L.DomEvent.addListener(this.options.styleEditorDiv,"mouseleave",this.enableLeafletActions,this)},addLeafletDrawEvents:function(){this.options.openOnLeafletDraw&&L.Control.Draw&&this.options.map.on("draw:created",function(t){this.initChangeStyle({target:t.layer})},this)},addButtons:function(){var t=L.DomUtil.create("button","leaflet-styleeditor-button styleeditor-nextBtn",this.options.styleEditorHeader);t.title=this.options.strings.tooltipNext,L.DomEvent.addListener(t,"click",function(t){this.hideEditor(),L.DomUtil.hasClass(this.options.controlUI,"enabled")&&this.createTooltip(),t.stopPropagation()},this)},clickHandler:function(t){this.options.enabled=!this.options.enabled,this.options.enabled?this.enable():(L.DomUtil.removeClass(this.options.controlUI,"enabled"),this.disable())},disableLeafletActions:function(){var t=this.options.map;t.dragging.disable(),t.touchZoom.disable(),t.doubleClickZoom.disable(),t.scrollWheelZoom.disable(),t.boxZoom.disable(),t.keyboard.disable()},enableLeafletActions:function(){var t=this.options.map;t.dragging.enable(),t.touchZoom.enable(),t.doubleClickZoom.enable(),t.scrollWheelZoom.enable(),t.boxZoom.enable(),t.keyboard.enable()},enable:function(){L.DomUtil.addClass(this.options.controlUI,"enabled"),this.options.map.eachLayer(this.addEditClickEvents,this),this.createTooltip()},disable:function(){this.options.editLayers.forEach(this.removeEditClickEvents,this),this.options.editLayers=[],this.options.layerGroups=[],this.hideEditor(),this.removeTooltip()},addEditClickEvents:function(t){if(this.options.useGrouping&&t instanceof L.LayerGroup)this.options.layerGroups.push(t);else if(t instanceof L.Marker||t instanceof L.Path){var e=t.on("click",this.initChangeStyle,this);this.options.editLayers.push(e)}},removeEditClickEvents:function(t){t.off("click",this.initChangeStyle,this)},hideEditor:function(){L.DomUtil.removeClass(this.options.styleEditorDiv,"editor-enabled")},showEditor:function(){var t=this.options.styleEditorDiv;L.DomUtil.hasClass(t,"editor-enabled")||L.DomUtil.addClass(t,"editor-enabled")},initChangeStyle:function(t){this.options.currentElement=this.options.useGrouping?this.getMatchingElement(t):t,this.showEditor(),this.removeTooltip(),t.target instanceof L.Marker?this.showMarkerForm():this.showGeometryForm()},showGeometryForm:function(){this.options.styleForm.showGeometryForm()},showMarkerForm:function(){this.options.styleForm.showMarkerForm()},createTooltip:function(){this.options.showTooltip&&(this.options.tooltipWrapper||(this.options.tooltipWrapper=L.DomUtil.create("div","leaflet-styleeditor-tooltip-wrapper",this.options.map.getContainer())),this.options.tooltip||(this.options.tooltip=L.DomUtil.create("div","leaflet-styleeditor-tooltip",this.options.tooltipWrapper)),this.options.tooltip.innerHTML=this.options.strings.tooltip)},getMatchingElement:function(t){for(var e=null,o=t.target,i=0;i