Better handling of random geojson with more properties
This commit is contained in:
parent
0a04418eee
commit
a13ab85372
@ -110,7 +110,12 @@ var handleData = function(data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data.command) { doCommand(data.command); delete data.command; }
|
if (data.command) { doCommand(data.command); delete data.command; }
|
||||||
if (data.hasOwnProperty("type") && data.type.indexOf("Feature") === 0) { doGeojson("geojson",data); }
|
if (data.hasOwnProperty("type") && data.type.indexOf("Feature") === 0) {
|
||||||
|
if (data.hasOwnProperty('properties') && data.properties.hasOwnProperty('title')) {
|
||||||
|
doGeojson(data.properties.title,data)
|
||||||
|
}
|
||||||
|
else { doGeojson("geojson",data); }
|
||||||
|
}
|
||||||
else if (data.hasOwnProperty("name")) { setMarker(data); }
|
else if (data.hasOwnProperty("name")) { setMarker(data); }
|
||||||
else {
|
else {
|
||||||
if (JSON.stringify(data) !== '{}') {
|
if (JSON.stringify(data) !== '{}') {
|
||||||
@ -2571,6 +2576,7 @@ function doCommand(cmd) {
|
|||||||
|
|
||||||
// handle any incoming GEOJSON directly - may style badly
|
// handle any incoming GEOJSON directly - may style badly
|
||||||
function doGeojson(n,g,l,o) {
|
function doGeojson(n,g,l,o) {
|
||||||
|
//console.log("GEOJSON",n,g,l,o)
|
||||||
var lay = l || g.name || "unknown";
|
var lay = l || g.name || "unknown";
|
||||||
// if (!basemaps[lay]) {
|
// if (!basemaps[lay]) {
|
||||||
var opt = { style: function(feature) {
|
var opt = { style: function(feature) {
|
||||||
@ -2602,12 +2608,29 @@ function doGeojson(n,g,l,o) {
|
|||||||
return st;
|
return st;
|
||||||
}}
|
}}
|
||||||
opt.pointToLayer = function (feature, latlng) {
|
opt.pointToLayer = function (feature, latlng) {
|
||||||
var myMarker = L.VectorMarkers.icon({
|
var myMarker;
|
||||||
icon: feature.properties["marker-symbol"] || "circle",
|
if (feature.properties.hasOwnProperty("SIDC")) {
|
||||||
markerColor: (feature.properties["marker-color"] || "#910000"),
|
myMarker = new ms.Symbol( feature.properties.SIDC.toUpperCase(), {
|
||||||
prefix: 'fa',
|
uniqueDesignation:unescape(encodeURIComponent(feature.properties.title)) ,
|
||||||
iconColor: 'white'
|
country:feature.properties.country,
|
||||||
});
|
direction:feature.properties.bearing,
|
||||||
|
additionalInformation:feature.properties.modifier,
|
||||||
|
size:24
|
||||||
|
});
|
||||||
|
myMarker = L.icon({
|
||||||
|
iconUrl: myMarker.toDataURL(),
|
||||||
|
iconAnchor: [myMarker.getAnchor().x, myMarker.getAnchor().y],
|
||||||
|
className: "natoicon",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
myMarker = L.VectorMarkers.icon({
|
||||||
|
icon: feature.properties["marker-symbol"] || "circle",
|
||||||
|
markerColor: (feature.properties["marker-color"] || "#910000"),
|
||||||
|
prefix: 'fa',
|
||||||
|
iconColor: 'white'
|
||||||
|
});
|
||||||
|
}
|
||||||
if (!feature.properties.hasOwnProperty("title")) {
|
if (!feature.properties.hasOwnProperty("title")) {
|
||||||
feature.properties.title = feature.properties["marker-symbol"];
|
feature.properties.title = feature.properties["marker-symbol"];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user