Hi Ethan
This is a sample i just construct. I managed to plot the map using InMemoryFeatureLayer. I have this problem:
- Adjust the icon with the tooltip of mouse.
- How can implement button for the InMemoryFeatureLayer to enabled it, so when i start the run the it not immediately execute the InMemoryFeatureLayer for plot.
- How can i delete the specific plot.
My code below throw me an exception:
KeyNotFoundException was unhandled
with remarks :
The given key was not present in the dictionary.
CODE:
namespace PointPlot
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
InMemoryFeatureLayer inmemoryFeatureLayer = new InMemoryFeatureLayer();
public MainWindow()
{
InitializeComponent();
}
private void Map1_Loaded(object sender, RoutedEventArgs e)
{
Map1.MapUnit = GeographyUnit.Meter;
LayerOverlay myOverlay = new LayerOverlay();
Map1.Overlays.Add(myOverlay);
myOverlay.TileCache = new FileBitmapTileCache(@"C:\Users\User\Documents\Visual Studio 2012\Projects\RasterMapViewer\RasterMapViewer\Cache\");
string[] files = System.IO.Directory.GetFiles(@"C:\Users\User\Desktop\DSI REFERENCE\Map Data\Raster");
foreach (string file in files)
{
GeoTiffRasterLayer tiffLayer = new GeoTiffRasterLayer(file);
myOverlay.Layers.Add(tiffLayer);
}
myOverlay.Open();
Map1.CurrentExtent = myOverlay.GetBoundingBox();
InMemoryFeatureLayer inmemoryFeatureLayer = new InMemoryFeatureLayer();
inmemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(new GeoImage(@"C:\Users\User\Documents\Visual Studio 2012\Projects\PointPlot\PointPlot\Icon\Point.png"));
//inmemoryFeatureLayer.InternalFeatures.Add("point", new Feature(@"C:\Users\User\Documents\Visual Studio 2012\Projects\PointPlot\PointPlot\Icon\Point.png"));
inmemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay markerOverlay = new LayerOverlay();
markerOverlay.Layers.Add(inmemoryFeatureLayer);
Map1.Overlays.Add("MarkerOverlay", markerOverlay);
Map1.Overlays.Add("MarkerOverlay", markerOverlay);
Map1.Refresh();
}
private void Map1_MapClick(object sender, MapClickWpfMapEventArgs e)
{
LayerOverlay markerOverlay = (LayerOverlay)Map1.Overlays["MarkerOverlay"];
InMemoryFeatureLayer inmemoryFeatureLayer = markerOverlay.Layers[0] as InMemoryFeatureLayer;
MultipolygonShape buffer = e.WorldLocation.Buffer(350, GeographyUnit.Meter, DistanceUnit.Kilometer);
inmemoryFeatureLayer.InternalFeatures.Add(new Feature(e.WorldLocation));
//Collection<Feature> deleteMarkers = inmemoryFeatureLayer.QueryTools.GetFeaturesWithin(buffer, ReturningColumnsType.NoColumns);
//if (deleteMarkers.Count > 0)
//{
// inmemoryFeatureLayer.InternalFeatures.Remove(deleteMarkers[0]);
//}
//else
//{
// inmemoryFeatureLayer.InternalFeatures.Add(new Feature(e.WorldLocation));
//}
Map1.Refresh();
}
private void Plot_ButtonClick(object sender, RoutedEventArgs e)
{
InMemoryFeatureLayer inMemoryLayer = (InMemoryFeatureLayer)Map1.FindFeatureLayer("InMemoryFeatureLayer");
inMemoryLayer.Open();
inMemoryLayer.EditTools.BeginTransaction();
inMemoryLayer.EditTools.Delete("MarkerOverlay");
inMemoryLayer.EditTools.CommitTransaction();
inMemoryLayer.Close();
Map1.Refresh(Map1.Overlays["InmemoryOverlay"]);
}
}
}
Regards,
Fathin