ThinkGeo.com    |     Documentation    |     Premium Support

Creating and modifying shape file

Hi,

My application reads 10k+ line text file. Each line contains lon, lat of a valve. I use simplemarker to add them to the map.

can you point me to some sample code for WPF (.net core if possible) which, after adding to the the marker overlay, create a shapefile for all the markers? I am also interested in editing the shapefile.

thanks,

Liang

Hi Liang_Lu,

In WPF if you choose simple marker overlay, each marker should be one control, so it will be so slow if the number is big.

Please try the InMemoryMarkerOverlay or if you just need shows the features like a marker, InmemoryFeatureLayer is enough. You just need to set the style like a marker:
inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(“Your Marker Image”);

And here is some sample code to edit a shape file:
ShapeFileFeatureLayer.CreateShapeFile();

        ShapeFileFeatureLayer layer = new ShapeFileFeatureLayer("");
        layer.FeatureSource.BeginTransaction();
        layer.FeatureSource.AddFeature();
        layer.FeatureSource.UpdateFeature();
        layer.FeatureSource.DeleteFeature();
        layer.FeatureSource.CommitTransaction();

Wish it’s helpful.

Regards,

Ethan

Hi Ethan,
Thank you for your explanation.
what are the pros and cons for InMemoryMarkerOverlay and InMemoryFeaturelayer? I’d like to have the ability to select each feature and edit its detailed info.

Thanks,

Liang

Hi Ethan,

another question, when using InMeoryFeatureLayer, how do I display both the shape and a label? As you suggested I add this code for each vavle:
InMemoryFeatureLayer inMemoryLayer = (InMemoryFeatureLayer)map.FindFeatureLayer(“InMemoryFeatureLayer”);

                inMemoryLayer.Open();
                inMemoryLayer.EditTools.BeginTransaction();
                Feature aFeature = new Feature(new PointShape((projection.ConvertToInternalProjection(place.Location.Geoposition.Longitude, place.Location.Geoposition.Latitude))));
                
                inMemoryLayer.InternalFeatures.Add(place.Name, aFeature);
                ;
                inMemoryLayer.EditTools.CommitTransaction();
                inMemoryLayer.Close();

But I am not able to display the feature names.

Thanks,

Liang

Hi Liang_Lu,

If you only want to select a feature and edit it’s information, InMemoryFeaturelayer is enough.

InMemoryMarkerOverlay introduce the marker related feature and should be easier to use.

If you want to shows the feature name as label (Not popup here), please just set text style for it, and you should want to save the name as an item in feature.ColumnValues.

Regards,

Ethan