AnsweredAssumed Answered

Querying feature info for L.esri.dynamicMapLayer “bbox must be specified”

Question asked by jcdege on Mar 3, 2016
Latest reply on Mar 7, 2016 by jcdege

I have a Leaflet map in which I am displaying an Esri ArcGIS REST layer, using L.esri.dynamicMapLayer(). The code that initializes this layer is passed the URL to the service and a comma-separated list of layers to be displayed - which service and which layers is configured by the user.

My task is to provide a means by which the user can click on the map and obtain feature information for the nearby facilities. I had been looking at L.esri.query(), which was simply inappropriate.

Looking at L.esri.DynamicMapLayer, I see that it has a function identify(), which should return an IdentifyFeatures object. But I'm not having any luck with using it.

Everything I try results in a "bbox must be specified" error.

The documentation for dynamicMapLayer is here: dynamic-map-layer.html

It includes:

Returns a new L.esri.services.IdentifyFeatures object that can be used to identify features on this layer. Your callback function will be passed a GeoJSON FeatureCollection with the results or an error.

dynamicMapLayer.identify() 
.at(latlng, latlngbounds, 5)
.run(function(error, featureCollection)
{
    console.log(featureCollection);
});

Note that .at() is called with a latlong object, a latlngbounds object, and "5".

But the documentation for the IdentifyFeatures object is here: identify-features.html

And it's documentation for at() is:

at( latlng) this Identifies feautres at a given

Only one argument. No second bounds argument, or third numeric argument, simply a LatLng. The LatLng links to the Leaflet code, indicating that it's an L.latLng object, containing a lat and a lng property.

The example code for IdentifyFeatures is even more confusing:

L.esri.identifyFeatures({ 
    url: 'http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer'
})
.on(map)
.at([45.543, -122.621])
.layers('visible:1')
.run(function(error, featureCollection, response){
    console.log("UTC Offset: " + featureCollection.features[0].properties.ZONE);
});

Here, we're not passing a L.latLng object, we're passing an array.

What gives? How am I supposed to use this?

Outcomes