Hello, I'm new to working with ThinkGeo. I'm working on an existing application and have run into some issues. I have a bunch of vertex locations which I need to translate to the ThinkGeo map display. Previously I had a List of InMemoryFeatureLayer and gave each polygon it's own default area and line styles within their own layer.
It worked but it seemed like a bad idea but it let me prototype the other features of the application. Now that the application is constructed I'm going back to enchance the ThinkGeo portions. First I created a custom style which draws based on the properties of my polygons. Doing this allowed me to get rid of my individual InMemoryFeatureLayer's and store all the features using a single layer.
Everything displays nicely on the map but when I try to remove a feature using it's ID it remains in the InternalFeatures of my layer and I can't figure out why. I've tested the id I'm asking to remove with the feature.Id and they match. Here's a condensed bit of code:
// Set Up Everything in ctor
_mapObstacleLayer = new InMemoryFeatureLayer();
_mapObstacleOverlay = new LayerOverlay();
_mapObstacleStyle = new ObstacleStyle();
_mapObstacleLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(_mapObstacleStyle);
_mapObstacleLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
_mapObstacleOverlay.Layers.Add(OBSTACLE_LAYER, _mapObstacleLayer);
_map.Overlays.Add(OBSTACLE_OVERLAY, _mapObstacleOverlay);
I then add my obstacles in a foreach
foreach(Obstacle obstacle in obstacles)
{
_mapObstacleLayer.InternalFeatures.Add(new Feature(obstacle.ToWellKnownText(), obstacle.ID.ToString()));
_mapObstacleStyle._Add(ref obstacle);
}
When I try to remove a certain obstacle using
_mapObstacleLayer.InternalFeatures.Remove(obstacle.ID.ToString());
Nothing happens. Before I would remove the Layer associated with the ID, but now since I only have one Layer I need to remove the obstacle from this layer. Like I stated earlier if I iterate over all the feature of the layer I do get a match for the correct ID but I don't know why it remains in the list after this call.
foreach (Feature feature in _mapObstacleLayer.InternalFeatures)
{
if (feature.Id == obstacle.ID.ToString())
Console.WriteLine("Match at " + feature.Id); // This is hit
else
Console.WriteLine("{0} != {1}", feature.Id, obstacle.ID.ToString());
}
I think I'm missing something with my transition from many-to-one Layers but I don't know what it is. Thanks!