I generate a geometry from a current view extent and create a layer via LayerFactory. Then, I select features in the that intersects with the created the geometry.
AGP zoom out all the way the layer extent and does not zoom back into the geometry extent. It happens only right after creating the layer. Afterwards, it works fine when layer does not need to be created again.
Here is the code
QueuedTask.Run(() =>
{
Envelope currentExtent = MapView.Active.Extent;
Geometry currentExtGeo = currentExtent.Clone();
var sq = new SpatialQueryFilter() { FilterGeometry = currentExtGeo,
SpatialRelationship = SpatialRelationship.Intersects };
CalledFlayer = LayerFactory.Instance.CreateLayer(CalledUri,
MapView.Active.Map, 0, CalledFLayerName) as FeatureLayer;
CalledFlayer.ClearSelection();
CalledFlayer.SetVisibility(true);
CalledFlayer.Select(sq);
MapView.Active.ZoomTo(currentExtGeo);//Supposed go back into original
//extent here but no
});
interestingly it works when I create another QueuedTask and move ZoomTo in it
QueuedTask.Run(() =>{...});
QueuedTask.Run(() =>
{
MapView.Active.ZoomTo(currentExtGeo);
});
Hi,
I have had the same situation but not with zoom. Esri stuff recommended to divide process inside QueuedTask.Run. I have a mind what it is a cache problem. Now if something does not work I try to divide one QueuedTask.Run to few if it possible.
Good to know!
I had a similar problem with the setCamera and isVisible methods when I was changing these properties on a large number of layers. The map frame display did not reliably update. Breaking out the calls into separate QueuedTask.Run blocks seemed to fix the issue, although it seems less efficient.