Dobrý den:
Takto vypadá můj web: https:\/\/brandonlprice.github.io\/landrecords\/. Jak mohu získat přístup k vlastnostem prvků pro vrstvu při spuštění find nebo query na vrstvě? Mám zobrazenou hodnotu feature.properties.length v .innerhtml, která ukazuje celkový počet vrácených prvků. Také bych chtěl být schopen zobrazit jednotlivé atributy pro každý prvek ve vrstvě v .innerhtml, když jsou kliknuty na mapě. onEachFeature by byla jedna možnost, i když nevím, jak to propojit s query.run nebo find.run. Jak to mohu udělat? Existuje nějaký jiný způsob, jak získat přístup k jednotlivým atributům? Moje ukázky kódu jsou níže.<\/P>
Query:<\/P>
<\/P>
<\/P>
<\/P>
function tmqueryFunction() {
latlng = markerLayer.getLatLng();
tmbufferResult.clearLayers();
document.getElementById("tractcounts").innerHTML = '';
if (document.getElementById("tm1").checked == true){
tmquery.nearby(latlng, distance);
tmquery.run(function (error, featureCollection, response) {
if (error) {
console.log(error);
return;
}
tmbufferResult.addData(featureCollection).addTo(map)
document.getElementById('tractcounts').innerHTML = 'Záznamy Tract Map: ' +
featureCollection.features.length;
});
map.fitBounds(L.geoJSON(featureCollection).getBounds());
});
}
}
<\/P>
<\/P>
<\/P>
<\/P>
Find<\/P>
<\/P>
<\/P>
<\/P>
function recordgo() {
var find = L.esri.find({
url: 'https:\/\/dpw.gis.lacounty.gov\/dpw\/rest\/services\/landrecords\/MapServer\/'
});
var recordnumber = document.getElementById("recordnumber").value;
buffergroup.clearLayers();
pmbufferResult.clearLayers();
srbufferResult.clearLayers();
tmbufferResult.clearLayers();
if (recordtype === "tract") {
find.layers('2')
.text(recordnumber)
.contains(false)
.fields('REFERENCE');
find.run(function (error, featureCollection, response) {
if (error) {
console.log(error);
return;
}
tmbufferResult.addData(featureCollection).addTo(map);
console.log('Nalezeno ' + featureCollection.features.length + ' prvek(ů)');
document.getElementById('recordinfo').innerHTML = featureCollection.features[0].properties.REFERENCE + ', Datum záznamu: ' + featureCollection.features[0].properties.RCRD_DATE;
console.log(featureCollection.features[0].properties.REFERENCE + ', Datum záznamu: ' + featureCollection.features[0].properties.RCRD_DATE);
map.fitBounds(L.geoJSON(featureCollection).getBounds())
});
}
<\/P>
<\/P>
<\/P>