Select to view content in your preferred language

WPF - Adding markers to Operational Layers using data from database rather than service

329
6
Jump to solution
2 weeks ago
Kaju
by
Emerging Contributor

I want to create markers on my map from a list containing C# objects with latitude and longitude properties, something similar to the following:

 

class Marker
{
  public int Long { get; set; }
  public int Lat { get; set; }
}

List<Marker> markers = databaseConnection.GetAllMarkers();

// Create Layer from markers
var layer = GetMarkerLayer(markers);

MapView.Map.OperationalLayers.Add(layer);

 

These markers need to be in a feature inside the "operationalLayers" list as I want to do clustering with them.

From my research, it seems like this is only possible by getting the data from a URL or some kind of service, but I want this functionality to be completely offline and mutable.

Is this possible?  

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Nicholas-Furness
Esri Regular Contributor

The simplest way to do this is to add Graphics to a Graphics Overlay.

See this sample: https://developers.arcgis.com/net/wpf/sample-code/add-graphics-with-renderer/

Look at the MakePointGraphicsOverlay() method.

A Graphic combines a geometry (in this case point) and optionally attributes, and can provide a symbol to determine what it will look like on the map (although you can optionally define a renderer on the Graphics Overlay to provide the symbol, which is what this sample does).

View solution in original post

0 Kudos
6 Replies
Nicholas-Furness
Esri Regular Contributor

The simplest way to do this is to add Graphics to a Graphics Overlay.

See this sample: https://developers.arcgis.com/net/wpf/sample-code/add-graphics-with-renderer/

Look at the MakePointGraphicsOverlay() method.

A Graphic combines a geometry (in this case point) and optionally attributes, and can provide a symbol to determine what it will look like on the map (although you can optionally define a renderer on the Graphics Overlay to provide the symbol, which is what this sample does).

0 Kudos
Kaju
by
Emerging Contributor

Thanks for the response Nicholas,

The current solution I have uses the Graphics Overlay functionality already, and I've implemented my own custom clustering with it before clustering officially came out for ArcGIS. It's quite a hacky solution and has its problems. That's why I ideally want to use the official ArcGIS clustering using the operational layers. 

Is it possible to use the official ArcGIS clustering on a graphics overlay? If so, could you point me to a sample?

Thanks Nicholas  

0 Kudos
dotMorten_esri
Esri Notable Contributor

Take a look at FeatureCollectionLayer / FeatureCollection for in-memory feature tables as well as just creating your own on on-disk Geodatabase using Geodatabase.Create and CreateTableAsync.

This will allow you to store data in feature tables that you can render using a feature layer and apply cluster rendering to using the FeatureReduction property.

Having said that, GraphicsOverlay also supports FeatureReduction.

Nicholas-Furness
Esri Regular Contributor

Feature Collections are also a great solution, and mean you can put your data anywhere in the operational layers stack (rather than drawn above it, as the graphics overlays are).

Just a couple of things to bear in mind:

  • While you can initially populate a FeatureCollectionTable at the Lite license level using one of these constructors, making subsequent changes to those features (adding, editing, or deleting features) uses the editing APIs, which will require a Basic license.
  • FeatureCollectionTables are schema-based, defining the fields expected for each feature, whereas GraphicsOverlays don't require that. This could be a good thing or not.

But as Morten mentioned, clustering is supported on Graphics Overlay for point graphics, so perhaps that'll provide what you need.

Kaju
by
Emerging Contributor

Thanks for your help Nicholas,

You mentioned I'd need a basic license for working with Feature Collections and I'm wondering if I'd need a license for the graphics overlay method of implementing feature reduction.

 

Thanks

0 Kudos
Nicholas-Furness
Esri Regular Contributor

A Lite license is all you'll need (it's free).

While you're developing you typically don't use a license, and you see the "Licensed for developer use only" watermark on your map. When it comes time to deploy, you need to use a license. You can learn more here: https://developers.arcgis.com/net/license-and-deployment/