diff --git a/assets/maps/contao-leaflet.js b/assets/maps/contao-leaflet.js index 7770339..2d42c8e 100644 --- a/assets/maps/contao-leaflet.js +++ b/assets/maps/contao-leaflet.js @@ -1 +1 @@ -L.Contao=L.Class.extend({includes:L.Mixin.Events,statics:{ATTRIBUTION:' | netzmacht'},maps:{},icons:{},initialize:function(){L.Icon.Default.imagePath="assets/leaflet/libs/leaflet/images/",this.setGeoJsonListeners(L.GeoJSON)},addMap:function(t,o){return this.maps[t]=o,this.fire("map:added",{id:t,map:o}),this},getMap:function(t){return"undefined"==typeof this.maps[t]?null:this.maps[t]},addIcon:function(t,o){return this.icons[t]=o,this.fire("icon:added",{id:t,icon:o}),this},loadIcons:function(t){for(var o=0;o=200&&t<300||304===t}function i(){void 0===r.status||n(r.status)?o.call(r,null,r):o.call(r,r,null)}var s=!1;if("undefined"==typeof window.XMLHttpRequest)return o(Error("Browser not supported"));if("undefined"==typeof e){var a=t.match(/^\s*https?:\/\/[^\/]*/);e=a&&a[0]!==location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}var r=new window.XMLHttpRequest;if(e&&!("withCredentials"in r)){r=new window.XDomainRequest;var p=o;o=function(){if(s)p.apply(this,arguments);else{var t=this,o=arguments;setTimeout(function(){p.apply(t,o)},0)}}}return"onload"in r?r.onload=i:r.onreadystatechange=function(){4===r.readyState&&i()},r.onerror=function(t){o.call(this,t||!0,null),o=function(){}},r.onprogress=function(){},r.ontimeout=function(t){o.call(this,t,null),o=function(){}},r.onabort=function(t){o.call(this,t,null),o=function(){}},r.open("GET",t,!0),r.send(null),s=!0,r}}); \ No newline at end of file +L.Contao=L.Class.extend({includes:L.Mixin.Events,statics:{ATTRIBUTION:' | netzmacht'},maps:{},icons:{},initialize:function(){L.Icon.Default.imagePath="assets/leaflet/libs/leaflet/images/",this.setGeoJsonListeners(L.GeoJSON)},addMap:function(t,o){return this.maps[t]=o,this.fire("map:added",{id:t,map:o}),this},getMap:function(t){return"undefined"==typeof this.maps[t]?null:this.maps[t]},addIcon:function(t,o){return this.icons[t]=o,this.fire("icon:added",{id:t,icon:o}),this},loadIcons:function(t){for(var o=0;o=200&&t<300||304===t}function i(){void 0===r.status||n(r.status)?o.call(r,null,r):o.call(r,r,null)}var s=!1;if("undefined"==typeof window.XMLHttpRequest)return o(Error("Browser not supported"));if("undefined"==typeof e){var a=t.match(/^\s*https?:\/\/[^\/]*/);e=a&&a[0]!==location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}var r=new window.XMLHttpRequest;if(e&&!("withCredentials"in r)){r=new window.XDomainRequest;var p=o;o=function(){if(s)p.apply(this,arguments);else{var t=this,o=arguments;setTimeout(function(){p.apply(t,o)},0)}}}return"onload"in r?r.onload=i:r.onreadystatechange=function(){4===r.readyState&&i()},r.onerror=function(t){o.call(this,t||!0,null),o=function(){}},r.onprogress=function(){},r.ontimeout=function(t){o.call(this,t,null),o=function(){}},r.onabort=function(t){o.call(this,t,null),o=function(){}},r.open("GET",t,!0),r.send(null),s=!0,r}}); \ No newline at end of file diff --git a/assets/maps/src/OverpassLayer.js b/assets/maps/src/OverpassLayer.js index df909f9..9eaf599 100644 --- a/assets/maps/src/OverpassLayer.js +++ b/assets/maps/src/OverpassLayer.js @@ -110,8 +110,10 @@ L.OverPassLayer = L.FeatureGroup.extend({ if (icon) { marker.setIcon(icon); } + } - L.contao.bindPopupFromFeature(marker, feature); + if (this.options.overpassPopup) { + marker.bindPopup(this.options.overpassPopup(feature, marker)); } this._map.fire('point:added', {marker: marker, feature: feature, latlng: latlng, type: type}); @@ -122,7 +124,9 @@ L.OverPassLayer = L.FeatureGroup.extend({ if (feature.properties) { L.Util.setOptions(layer, feature.properties.options); - L.contao.bindPopupFromFeature(layer, feature); + if (this.options.overpassPopup) { + layer.bindPopup(this.options.overpassPopup(feature, layer)); + } this._map.fire('feature:added', {feature: feature, layer: layer}); } diff --git a/module/dca/tl_leaflet_layer.php b/module/dca/tl_leaflet_layer.php index fd9f175..9082c3f 100644 --- a/module/dca/tl_leaflet_layer.php +++ b/module/dca/tl_leaflet_layer.php @@ -221,6 +221,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = array 'boundsMode', 'minZoom', 'overpassEndpoint', + 'overpassPopup' ), 'style' => array( 'amenityIcons' @@ -911,5 +912,19 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = array ), 'sql' => "blob NULL", ), + 'overpassPopup' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['overpassPopup'], + 'exclude' => true, + 'inputType' => 'textarea', + 'eval' => array( + 'preserveTags' => true, + 'decodeEntities' => true, + 'allowHtml' => true, + 'rte' => 'ace|javascript', + 'tl_class' => 'clr' + ), + 'sql' => "mediumtext NULL" + ), ) ); diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/OverpassLayerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/OverpassLayerMapper.php index 398c354..95ccca8 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/OverpassLayerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/OverpassLayerMapper.php @@ -77,6 +77,10 @@ class OverpassLayerMapper extends AbstractLayerMapper if ($model->onEachFeature) { $definition->setOnEachFeature(new Expression($model->onEachFeature)); } + + if ($model->overpassPopup) { + $definition->setOption('overpassPopup', new Expression($model->overpassPopup)); + } } /**