Boss: "Can filter the feature layer and then have it zoom in to that filtered section?"
Me: "For sure, shouldn't be a problem"
And so, here I am. For the life of me, I cannot get what seems like it should be a simple task to work.
The filtering of the feature layer is accomplished using the defintionExpression. So with that the map loads and the only polygon visible is what matches the defintionExpression. However, what I have failed to figure out, is how I can get the map to zoom into and center on that visible polygon.
Here is a link to the codepen for some understanding of what I am trying to accomplish. You will notice in the pen that the visible polygon is not centered.
Any and all help is immensely appreciated.
Mark
Solved! Go to Solution.
Mark,
It is pretty easy. Just query the layer views extent.
map.add(DivFeatureLayer);
view.whenLayerView(DivFeatureLayer).then(function(layerView){
layerView.watch("updating", function(val){
if(!val){ // wait for the layer view to finish updating
layerView.queryExtent().then(function(results){
view.goTo(results.extent); // go to the extent of all the graphics in the layer view
});
}
});
});
Mark,
It is pretty easy. Just query the layer views extent.
map.add(DivFeatureLayer);
view.whenLayerView(DivFeatureLayer).then(function(layerView){
layerView.watch("updating", function(val){
if(!val){ // wait for the layer view to finish updating
layerView.queryExtent().then(function(results){
view.goTo(results.extent); // go to the extent of all the graphics in the layer view
});
}
});
});
Aw man, I feel like a complete tool. You responded so fast!
Thank you my friend. Keep being awesome!
Mark