I have been trying to start working on the javascript API. I need to retrieve the feature layer name if any point features are there within the extent values. The extent values will differ, whenever we are performing zoom in or zoom out process. If not possible, how can we do this in some other way?
Thanks in Advance.
Solved! Go to Solution.
The snippet below is from this sample
// Watch view's stationary property for becoming true.
watchUtils.whenTrue(view, "stationary", function() {
// Get the new center of the view only when view is stationary.
if (view.center) {
var info =
"<br> <span> the view center changed. </span> x: " +
view.center.x.toFixed(2) +
" y: " +
view.center.y.toFixed(2);
displayMessage(info);
}
// Get the new extent of the view only when view is stationary.
if (view.extent) {
var info =
"<br> <span> the view extent changed: </span>" +
"<br> xmin:" +
view.extent.xmin.toFixed(2) +
" xmax: " +
view.extent.xmax.toFixed(2) +
"<br> ymin:" +
view.extent.ymin.toFixed(2) +
" ymax: " +
view.extent.ymax.toFixed(2);
displayMessage(info);
}
});
In the 4.x api you just watch the views stationary property to be true then get the view.extent property.
The snippet below is from this sample
// Watch view's stationary property for becoming true.
watchUtils.whenTrue(view, "stationary", function() {
// Get the new center of the view only when view is stationary.
if (view.center) {
var info =
"<br> <span> the view center changed. </span> x: " +
view.center.x.toFixed(2) +
" y: " +
view.center.y.toFixed(2);
displayMessage(info);
}
// Get the new extent of the view only when view is stationary.
if (view.extent) {
var info =
"<br> <span> the view extent changed: </span>" +
"<br> xmin:" +
view.extent.xmin.toFixed(2) +
" xmax: " +
view.extent.xmax.toFixed(2) +
"<br> ymin:" +
view.extent.ymin.toFixed(2) +
" ymax: " +
view.extent.ymax.toFixed(2);
displayMessage(info);
}
});
Ah! Thanks for the help! I'll check it out soon.
Thank you Mr.Ben Elan.. (view.extent) property is working now... Within this map extent can we able to retrieve the count of point features from the feature layer in the version of 4x series? This functionality is working in 3x series here. But according to the 4x series still I am analyzing about it whether or not it is possible.
See this sample for querying a layers view.
The relevant code being
view.whenLayerView(featureLayer).then(function(layerView) {
layerView.watch("updating", function(value) {
if (!value) {
// wait for the layer view to finish updating
// query all the features available for drawing.
layerView
.queryFeatures({
geometry: view.extent,
returnGeometry: true
})
.then(function(results) {
// Get count of features
console.log(results.features.length)
})
.catch(function(error) {
console.error("query failed: ", error);
});
}
});
});