This project has moved and is read-only. For the latest updates, please go here.

Refresh layer after edit

Topics: SharpMap v0.9 / v1.x
Aug 22, 2011 at 7:19 PM

I have a vector layer. Its underlying data source is a GeometryFeatureProvider.

I implemented a simple delete tool that enables to delete object from map by clicking it.

It deletes object from the underlying data source, but the layer does not refreshes, so the deleted
object is still there. It is removed from the datasource, but not from the map...

After removing and adding the layer to the map again,  the deleted object disappears, so it is OK.

How can I do the refreshment instead of removing/re-adding layer to the map again? 

Aug 22, 2011 at 8:52 PM

What type of datasource are you using?

If you're using GeometryProvider you need to reset the datasource after applying changes.

Aug 22, 2011 at 10:02 PM
Edited Aug 22, 2011 at 10:03 PM

A simple customized one: FeatureGeometryProvider that reads geometries in WKT format from a file.

Thx, I'll try that!

Aug 23, 2011 at 7:05 AM

The feature geometryprovider does not monitor the datasource for changes, it just keeps an in-memory copy of it so you need to do

layer.Datasource = new GeometryFeatureProvider(mydatasource);

after editing features in the layer 

Aug 23, 2011 at 8:55 AM

Thx Petlof, now it is working! :)