Select to view content in your preferred language

Access individual feature properties when running l.esri.find or l.esri.query

941
0
11-30-2020 05:44 PM
Labels (1)
by Anonymous User
Not applicable

Hello:

Here is what my site looks like: https://brandonlprice.github.io/landrecords/. How can I access the feature properties for a layer when running a find or a query on a layer? I have the the feature.properties.length being displayed in a .innerhtml to show the total count of features returned. I also would like to be able to display the individual attributes for each feature in a layer in a .innerhtml when they are clicked on in the map. The onEachFeature would be one way although I do not know how to link that to the query.run or find.run. How can I do that? Are there any other way to access the individual attributes. My code snippets are below.

Query:

 

 

 

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 = 'Tract Map Records: ' + 
  featureCollection.features.length;	  
  });  
  map.fitBounds(L.geoJSON(featureCollection).getBounds());
});
}
}

 

 

 

 

Find

 

 

 

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('Found ' + featureCollection.features.length + ' feature(s)');
  document.getElementById('recordinfo').innerHTML = featureCollection.features[0].properties.REFERENCE + ', Record Date: ' + featureCollection.features[0].properties.RCRD_DATE;
  console.log(featureCollection.features[0].properties.REFERENCE + ', Record Date: ' + featureCollection.features[0].properties.RCRD_DATE);
  map.fitBounds(L.geoJSON(featureCollection).getBounds())
});
  }

 

 

 

0 Kudos
0 Replies