Hi
At the moment we are moving or updating the information or the style of a feature in a layer replacing the feature in the InternalFeatures collection.
Something similar to:
private bool UpdateNodePosition()
{
if (m_UpdatingNodes)
{
return false;
}
m_UpdatingNodes = true;
bool isOpen = m_LayerNodes.IsOpen;
if (!isOpen)
{
m_LayerNodes.Open();
}
try
{
GeoCollection<Feature> coll = m_LayerNodes.InternalFeatures;
try
{
string nodeState = NODESTATUS_OK;
if (m_CurrExtendLatLon != null)
{
double angle = Math.PI * m_PosState / 180.0;
m_PosState += 15;
if (m_PosState >= 360)
{
m_PosState = 0;
}
double latitude = m_CurrExtendLatLon.GetCenterPoint().Y;
double longitude = m_CurrExtendLatLon.GetCenterPoint().X;
latitude += Math.Sin(angle) * NODE_MOVE_RADIUS;
longitude += Math.Cos(angle) * NODE_MOVE_RADIUS;
Feature feature = new Feature(longitude, latitude, KEY_Node);
feature.ColumnValues[NODE_TITLE_COLNAME] = "Test";
if (!String.IsNullOrEmpty(nodeState))
{
feature.ColumnValues[NODE_STATE_COLNAME] = nodeState;
}
if (coll.Contains(feature.Id))
{
coll.Remove(feature.Id); // remove the old feature if it already exists
}
coll.Add(feature.Id, feature);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(String.Format("Unable to create the feature from the element\n{0}", ex));
}
}
finally
{
if (!isOpen)
{
m_LayerNodes.Close();
}
m_UpdatingNodes = false;
}
return true;
}
The UI presentation of the feature is obtained by a ValueStyle linked to the Column value.
After the features are updated then I need to call a refresh to the overlay contaning the layer:
private async Task TestMoveNodeAsync()
{
if (UpdateNodePosition())
{
await m_OverlayNodes.RefreshAsync();
}
}
where m_OverlayNodes is:
private readonly FeatureLayerWpfDrawingOverlay m_OverlayNodes;
If the refresh is not called then the feature is not moved/updated.
Is there a better way to move/update the feature without calling the refresh ?
Thanks
Domenico