Geopackage FeatureLayers and Cloning (Overview Map)

473
3
Jump to solution
09-17-2019 03:43 PM
justinpenka
New Contributor II

I'm attempting to create an overview map of my main map, which is populated with FeatureLayers from a Geopackage. According to the documentation to use a single FeatureLayer on multiple maps the layer should be cloned, and the clone used on the secondary Map. When using Geopackage layers this doesn't appear to work. The cloned layer is returned in a "NotLoaded" LoadStatus.

GeoPackage geoPackage = await GeoPackage.OpenAsync(geoPackagePath);

FeatureTable geoPackageTable = geoPackage.GeoPackageFeatureTables.FirstOrDefault();

if (geoPackageTable == null) { return; }

FeatureLayer newLayer = new FeatureLayer(geoPackageTable);
await newLayer.LoadAsync();

FeatureLayer cloneLayer = (FeatureLayer)newLayer.Clone();

SourceMap.OperationalLayers.Add(newLayer);
CloneMap.OperationalLayers.Add(cloneLayer);

Thus null values are returned for many of the FeatureLayer properties, such as the Renderer or FullExtent. This also means that the Layer itself is not visible on the map.

Source layer on the top map, cloned layer on the bottom map.

To load the layer we would call LoadAsync(), but doing so on the cloned layer, creates the following error: 

Error returned on LoadAsync() of cloned layer

Is this a bug, or is there something I am missing about cloning Geopackage FeatureLayers?

0 Kudos
1 Solution

Accepted Solutions
dotMorten_esri
Esri Frequent Contributor

The on-disk feature tables acts slightly different and I don't believe a clone would really work, as the underlying datasource/featuretable would still be the same.

Instead I think you'd need to open a second instance of the geopackage instead - that should give you a better clone of the feature table. 

View solution in original post

3 Replies
dotMorten_esri
Esri Frequent Contributor

The on-disk feature tables acts slightly different and I don't believe a clone would really work, as the underlying datasource/featuretable would still be the same.

Instead I think you'd need to open a second instance of the geopackage instead - that should give you a better clone of the feature table. 

justinpenka
New Contributor II

Thanks Morten!

0 Kudos
ShaneHulligan
New Contributor

How did you resolve this issue?

I am having the same problem.

Cheers

0 Kudos