window.WPLeafletMapPlugin = window.WPLeafletMapPlugin || [];
window.WPLeafletMapPlugin.push(function WPLeafletjsonShortcode() {/**/
var src = 'https://ostsee.tours/wp-content/uploads/2020/01/ruegen.geojson';
var default_style = {};
var rewrite_keys = {
stroke : 'color',
'stroke-width' : 'weight',
'stroke-opacity' : 'opacity',
fill : 'fillColor',
'fill-opacity' : 'fillOpacity',
};
// htmlspecialchars converts & to "&"; maybe unnecessarily, and maybe 3x
var ampersandRegex = /&(?:amp;){1,3}/g
var layer = L.ajaxGeoJson(src.replace(ampersandRegex, '&'), {
type: 'json',
style : layerStyle,
onEachFeature : onEachFeature,
pointToLayer: pointToLayer
});
var fitbounds = 0;
var circleMarker = 0;
var popup_text = window.WPLeafletMapPlugin.unescape("");
var popup_property = "";
var group = window.WPLeafletMapPlugin.getCurrentGroup();
var markerOptions = window.WPLeafletMapPlugin.getIconOptions({});
layer.addTo( group );
window.WPLeafletMapPlugin.geojsons.push( layer );
if (fitbounds) {
layer.on('ready', function () {
this.map.fitBounds( this.getBounds() );
});
}
function layerStyle (feature) {
var props = feature.properties || {};
var style = {};
function camelFun (_, first_letter) {
return first_letter.toUpperCase();
};
for (var key in props) {
if (key.match('-')) {
var camelcase = key.replace(/-(\w)/, camelFun);
style[ camelcase ] = props[ key ];
}
// rewrite style keys from geojson.io
if (rewrite_keys[ key ]) {
style[ rewrite_keys[ key ] ] = props[ key ];
}
}
return L.Util.extend(style, default_style);
}
function onEachFeature (feature, layer) {
var props = feature.properties || {};
var text;
if (0) {
text = window.WPLeafletMapPlugin.propsToTable(props);
} else {
text = popup_property
? props[ popup_property ]
: window.WPLeafletMapPlugin.template(
popup_text,
feature.properties
);
}
if (text) {
layer.bindPopup( text );
}
}
function pointToLayer (feature, latlng) {
if (circleMarker) {
return L.circleMarker(latlng);
}
return L.marker(latlng, markerOptions);
}});