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?
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).
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
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.
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:
But as Morten mentioned, clustering is supported on Graphics Overlay for point graphics, so perhaps that'll provide what you need.