Hi,
I have a super simple prototype app illustrating my problem which you can download from here:
https://dl.dropboxusercontent.com/u/2497368/PlanningPrototype.zip
I have an app that allows me to switch between SelectionMode and my own "Add Points Mode" using the S and P keys:
Next I try to add labels by adding this after I setup the MapPointLayer:
Any ideas?
Thanks,
Anthony
I have a super simple prototype app illustrating my problem which you can download from here:
https://dl.dropboxusercontent.com/u/2497368/PlanningPrototype.zip
I have an app that allows me to switch between SelectionMode and my own "Add Points Mode" using the S and P keys:
private void MapContainer_OnKeyUp(object sender, KeyEventArgs e)
{
_ignoreClick = true;
if (e.Key == Key.P)
{
_ignoreClick = false;
_map.FunctionMode = FunctionMode.None;
_map.Cursor = Cursors.Cross;
}
if (e.Key == Key.S)
{
_map.FunctionMode = FunctionMode.Select;
}
}
I'm setting up a MapPointLayer like so: _featureSet = new FeatureSet(FeatureType.Point);
DataColumn column = new DataColumn("PointID");
_featureSet.DataTable.Columns.Add(column);
_pointLayer = (MapPointLayer)_map.Layers.Add(_featureSet);
_pointLayer.Symbolizer = new PointSymbolizer(System.Drawing.Color.Red, DotSpatial.Symbology.PointShape.Star, 30);
_pointLayer.SelectionSymbolizer = new PointSymbolizer(System.Drawing.Color.Yellow, DotSpatial.Symbology.PointShape.Star, 30);
Then I'm subscribing to the GeoMouseMove event and Click event of the Map: private void MapOnMouseMove(object sender, GeoMouseArgs geoMouseArgs)
{
// Storing this as it doesn't seem to be available in the Click event
_geoMouseArgs = geoMouseArgs;
}
void MapOnClick(object sender, EventArgs e)
{
if (_ignoreClick) return;
Coordinate coord = _map.PixelToProj(_geoMouseArgs.Location);
Point point = new Point(coord);
IFeature feature = _featureSet.AddFeature(point);
feature.DataRow["PointID"] = _pointId++;
_map.ResetBuffer();
}
This all works fine, although the selection tool doesn't work quite as expected. If I add 3 points to the map and then use the selection tool to select one of them; when I select another one, the first one doesn't unselect. Strange, but I can get around it with a call to _pointLayer.UnSelectAll() in the Click handler.Next I try to add labels by adding this after I setup the MapPointLayer:
_labelLayer = new MapLabelLayer(_pointLayer);
_labelLayer.FeatureLayer = (IMapFeatureLayer)_pointLayer;
_labelLayer.FeatureSet = _featureSet;
_labelLayer.Symbology.Categories[0].Expression = "[PointID]";
_labelLayer.Symbolizer.FontSize = 8F;
_labelLayer.Symbolizer.BorderVisible = false;
_labelLayer.Symbolizer.DropShadowEnabled = false;
_labelLayer.Symbolizer.OffsetX = 20;
_pointLayer.LabelLayer = _labelLayer;
_pointLayer.ShowLabels = true;
This does one of two things, it stops the points from being selectable at all, and it only adds a label to the first point, none of the remaining points receive a label. I seem to be able to fix the remaining labels by adding this to the end of the Click handler: _featureSet.ShapeIndices = null;
_featureSet.UpdateExtent();
_pointLayer.AssignFastDrawnStates();
_labelLayer.CreateLabels();
However I still can't select my points!Any ideas?
Thanks,
Anthony