Zoom on layer from a .GPKG not working when using CreateLayer

174
2
4 weeks ago
TommyBouchard
New Contributor

HI, 

I am using ArgGis Pro 3.2.2 and my data is in a .gpkg file.

Zooming on the layer works when I add it from manualy(drag and drop form Catalog).

If I do it in my c# code using the CreateLayer, it doesn't work.

EX:

LayerFactory.Instance.CreateLayer(new Uri("C:\Temp\data.gpkg\Name"), map, map.Layers.Count, "name");

Tommy

0 Kudos
2 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

You need to call MapView.Active.ZoomToAsync after creating layer:

var layer = LayerFactory.Instance.CreateLayer(newUri("C:\Temp\data.gpkg\Name"), map, map.Layers.Count, "name");
var fc = (layer as FeatureLayer).GetFeatureClass();
zoomToEnv = fc.GetExtent().Clone() as ArcGIS.Core.Geometry.Envelope;
if (zoomToEnv != null) MapView.Active.ZoomToAsync(zoomToEnv);
0 Kudos
TommyBouchard
New Contributor

Thanks, I can use this to bypass my problem temporarily.

Outside of the c# code, in arcgis pro, if I right click on the layer and click on Zoom on the layer, it doesn't work.

It does a weird zoom out not centered on my polygons. 

 

 

0 Kudos