Style dynamic map overlay using renderer from *.lyrx file

639
1
03-06-2018 08:02 AM
RichardReinicke
Occasional Contributor II

Hi,

I have a new use case where I could need some help to get in the right direction.

Actually I receive live data via events, measurements with coordinates and I want to add them dynamically to a map overlay. I have a separate *.lyrx file with a symbology / classification that I want to use for the overlay. So how can I realize that?

Is it possible to create an overlay or map layer with an in memory data source to which I add points at runtime? Is there such a layer type and does it refresh automatically or by command?

Any hints and help would be very appreciated.

0 Kudos
1 Reply
RichardReinicke
Occasional Contributor II

Now I have a similar task at another part of my add-in. Again I want to create a feature layer based on an in-memory datastore. I want to add a couple of MapPoints to that in-memory datastore and my layer to update accordingly.

So is it possible to create an instance of FeatureLayer on an in-memory data source?

If it`s not passible:
Can I create a collection/bag of MapPoints and add them as a standard Graphic Overlay at once?


I have some code already but LayerFactory.Instance.CreateFeatureLayer() doesn't accept my CIMInMemoryDatasetDataConnection also I didn`t find some more detailled docs on how to use this type of connection

CIMInMemoryDatasetDataConnection inMemoryDatastore = new CIMInMemoryDatasetDataConnection();
inMemoryDatastore.Dataset = "Wegpunkte";
FeatureLayer waypointLyr = LayerFactory.Instance.CreateFeatureLayer(
    inMemoryDatastore, 
    MapView.Active.Map, 
    LayerPosition.AddToTop, 
    "Wegpunkte") as FeatureLayer;
var createWaypointsOperation = new EditOperation();

using (RowCursor shapefileCursor = shapefileData.Search(null, false))
{
    while (shapefileCursor.MoveNext())
    {
        using (Feature feature = (Feature)shapefileCursor.Current)
        {
            ArcGIS.Core.Geometry.Geometry geom = feature.GetShape();
            if (geomType == GeometryType.Point)
            {
                createWaypointsOperation.Create(waypointLyr, geom as MapPoint);
            } else if (geomType == GeometryType.Polyline)
            {
                using (IEnumerator<MapPoint> enumPts = ((Polyline)geom).Points.GetEnumerator())
                {
                    while (enumPts.MoveNext())
                    {
                        createWaypointsOperation.Create(waypointLyr, enumPts.Current);
                    }
                }
            }
        }
    }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos