'Leaflet List marker shapefile
Salutations, I'm working with a shapefile with the leaflet library. I would need to retrieve the list of markers from the shapefile, for example by retrieving the station code so that I can then search for a point on the map. Below is my code:
var watercolor = L.tileLayer('http://mt0.google.com/vt/lyrs=s&hl=en&x={x}&y={y}&z={z}', {});
var geo = L.geoJson({features: []}, {
onEachFeature: function popUp(feature, layer) {
var out = [];
if (feature.properties) {
for (var key in feature.properties) {
out.push(key + ": " + feature.properties[key]);
}
layer.bindPopup(out.join("<br />"));
}
}
});
var myMap = L.map('divMapID', {
center: L.latLng(39.15097955985934, 9.019421210403138),//Valori prec: [39, 9],
`enter code here` zoom: 10,
minZoom: 3,
layers: [watercolor, geo]
});
//data è un oggetto geoJson
var base = 'testo.zip';
shp(base).then(function (data) {
geo.addData(data);
});
var baseMaps = {
"BaseLayer": watercolor
};
var overlays = {
"shapefile": geo
};
L.control.layers(baseMaps, overlays).addTo(myMap);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
