Slightly better geojson (make url property into link), Make title first in list

This commit is contained in:
Dave Conway-Jones 2021-02-23 08:58:41 +00:00
parent 5c065627c2
commit 3345189d32
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF

View File

@ -2381,6 +2381,7 @@ function doGeojson(n,g,l,o) {
delete feature.properties["fill-color"]; delete feature.properties["fill-color"];
delete feature.properties["fill"]; delete feature.properties["fill"];
delete feature.properties["fill-opacity"]; delete feature.properties["fill-opacity"];
delete feature.properties["stroke-opacity"];
} }
if (feature.hasOwnProperty("style")) { if (feature.hasOwnProperty("style")) {
//console.log("GSTYLE", feature.style) //console.log("GSTYLE", feature.style)
@ -2404,13 +2405,18 @@ function doGeojson(n,g,l,o) {
if (!feature.properties.hasOwnProperty("title")) { if (!feature.properties.hasOwnProperty("title")) {
feature.properties.title = feature.properties["marker-symbol"]; feature.properties.title = feature.properties["marker-symbol"];
} }
if (feature.properties.hasOwnProperty("url")) {
feature.properties.url = "<a target='_new' href='"+feature.properties.url+"'>"+feature.properties.url+"</a>";
}
delete feature.properties["marker-symbol"]; delete feature.properties["marker-symbol"];
delete feature.properties["marker-color"]; delete feature.properties["marker-color"];
delete feature.properties["marker-size"]; delete feature.properties["marker-size"];
return L.marker(latlng, {title:feature.properties.title || "", icon:myMarker,}); var nf = {title:feature.properties.title, name:feature.properties.name};
feature.properties = Object.assign(nf, feature.properties);
return L.marker(latlng, {title:feature.properties.title || "", icon:myMarker});
} }
opt.onEachFeature = function (f,l) { opt.onEachFeature = function (f,l) {
if (f.properties) { l.bindPopup('<pre>'+JSON.stringify(f.properties,null,' ').replace(/[\{\}"]/g,'')+'</pre>'); } if (f.properties) { l.bindPopup('<pre style="overflow-x: scroll">'+JSON.stringify(f.properties,null,' ').replace(/[\{\}"]/g,'')+'</pre>'); }
} }
markers[n] = L.geoJson(g,opt); markers[n] = L.geoJson(g,opt);
markers[n].lay = lay; markers[n].lay = lay;