0

I'm using Esri-Leaflet and whenever I try to use getFeature() the console.log returns "undefined".

There are no other errors to accompany the undefined message.

var service = L.esri.featureLayer({url: 'https://services1.arcgis.com/example/arcgis/rest/services/LayerName/FeatureServer/0'});
var objID = parseInt("4");
var featurePoly = service.getFeature(objID);
console.log(service.featurePoly);

A feature of ObjectID of 4 does exist. The feature service is reachable.

Any thoughts on where I might be going wrong?

bumped to the homepage by Community 2 days ago

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

0

The answer to this seems to be that:

The featureService must have been added to the map. .addTo('map'); The map must be set to viewing coordinates that causes the features to be returned to the map.

It's not possible to work with features that have not been added to the map, apparently.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.