Mapsui: How to cancel/undo changes in a layer? Polygon/Line issue.

Created on 7 Apr 2018  路  3Comments  路  Source: Mapsui/Mapsui

Hi Paul,

I鈥檓 trying to create Undo/Cancel functionality and I have issue with Polygons and Lines.

The scenario:
...the polygon (can be a few) is in the TargetLayer
EditLayer.Features = TargetLayer.Features.Copy
EditMode = Modify
TargetLayer.Clear
...now are changes in the objects in EditLayer
...here I want to cancel/undo all changes and restore previous Features in TargetLayer

I use local temp Features, and after the cancel I use them to restore original TargetLayer (before changes).
It works.
But [the ISSUE] when I repeat the scenario, after copy TL.Features to EL I see the objects just after changes (no undo) and when I click on any of the polygon point the objects jump to correct state (without changes, like after undo).

With point always is fine, with polygons and lines is the issue.

What is wrong? (any sample?)

Many Thanks,
Lukasz

All 3 comments

Hi Lukasz! Good to see you here :)

This is about the editing functionality that I have not yet integrate into Mapsui, but will soon.

If I understand you correctly there is only a brief moment that you do not see what you expect. After the second time you start editing you see the polygons that you cancelled in the previous try. Is this correct?

I don't have any immediate idea what could be wrong. It could be something with caching. But there is no caching in the layer itself. There is caching on the features, but it should not be influenced by the copy, but perhaps it does. What if you clear the RendereGeometry of all features before you copy?

If this fixes the problem the copy method probably does not create a copy of the RenderdGeometry field. I think this explanation is quite likely.

foreach (var feature in features)
{
feature.RenderedGeometry.Clear();
}

works perfectly, Thanks! 馃憤

馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Kayumiy picture Kayumiy  路  9Comments

charlenni picture charlenni  路  3Comments

ricardoboss picture ricardoboss  路  5Comments

willy40 picture willy40  路  6Comments

lukaszpitulski picture lukaszpitulski  路  5Comments