New FeatureLayer does not render existing data

386
4
08-19-2020 01:59 AM
GernotNeppert
New Contributor

Hello,

I'm using LayerFactory.Instance.CreateFeatureLayer(...) to create new Layers based on .lyrx files.

The Layer's "dataset" references an existing feature-table in the geo-database.

What I expect: ArcGIS Pro creates the new layer and renders the existing geo-objects from the feature-table.

What happens: ArcGIS Pro creates the new layer, but does not render any objects. The layer is empty. However, when I open the Layer's "attribute table", using the context menu, I can see the data!

Obviously, I'm missing something. Is there a way to enforce the rendering of existing data programmatically?

0 Kudos
4 Replies
GernotNeppert
New Contributor

4 weeks have passed since I posted this question.

In the meantime, we've tried every conceivable way to get this to work, but to no avail...

Seems we have a profound misunderstanding of how layers relate to their database tables.

Some more background:

We have an ArcGIS Pro Addin with a remote interface to a client application. When the addin initializes, it creates the database with the appropriate tables. Afterwards, the client application may start sending "draw requests" to the Addin.

Once the user opens a map view, the Addin reacts by adding the expected feature Layers. However, even though there's already data in the dataset, nothing appears on the Map

0 Kudos
BrianBulla
Occasional Contributor III

This is just a guess, but I'm pretty sure when you bring in a .lyrx file it also brings in any scale references, etc. that were set at the time you created the .lyrx.  Do you have anything like that set that would prevent the data from displaying properly?

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

 I use this functionality often and never have seen an issue, so I assume this issue is specific to your layer definition and/or data.  In the attribute table you can select a feature and then use the 'zoom to' function to see where that takes you on the map, maybe there's a projection problem.  If you add the layer through the UI in Pro it works fine? Is it failing only when you add it through the SDK?

0 Kudos
GernotNeppert
New Contributor

Thank you for your replies!

We've investigated the problem further and found out something interesting:

Our geo-data will be displayed if we do the following two things after creating the FeatureLayer:

  1. Invoke SaveEditsAsync() on the current Project.
  2. Invoke Redraw() on the active MapView.

Neither operation is sufficient on on its own, you need to do both of them!

So, unsatisfiying as it may be, we'll use this workaround until someon comes up with a better solution...

0 Kudos