private void Map1_MapClick(object sender, SlimGis.MapKit.WinForms.MapMouseEventArgs e) { // We added a ShapefileLayer in the Loaded event, // it's default name is the name of the shapefile. // so here, we could find the layer back by the shapefile name without extension. FeatureLayer featureLayer = Map1.FindLayer <FeatureLayer>("countries-900913"); Feature identifiedFeature = IdentifyHelper.Identify(featureLayer, e.WorldCoordinate, Map1.CurrentScale, Map1.MapUnit).FirstOrDefault(); MemoryLayer dynamicLayer = Map1.FindLayer <MemoryLayer>("Highlight Layer"); if (dynamicLayer == null) { dynamicLayer = new MemoryLayer { Name = "Highlight Layer" }; dynamicLayer.UseRandomStyle(); Map1.AddStaticLayers("HighlightOverlay", dynamicLayer); } dynamicLayer.Features.Clear(); if (identifiedFeature != null) { dynamicLayer.Features.Add(identifiedFeature); } Map1.Overlays["HighlightOverlay"].Refresh(); }
private void Map1_MapSingleClick(object sender, MapClickEventArgs e) { Feature identifiedFeature = IdentifyHelper.Identify(dataLayer, e.WorldCoordinate, Map1.CurrentScale, Map1.MapUnit).FirstOrDefault(); if (identifiedFeature != null) { double areaInSquareKilometer = ((GeoAreaBase)identifiedFeature.Geometry).GetArea(GeoUnit.Meter, AreaUnit.SquareKilometers); identifiedFeature.FieldValues.Add("Area", $"{areaInSquareKilometer:N2} sq. km"); MemoryLayer highlightLayer = Map1.FindLayer <MemoryLayer>("HighlightLayer"); highlightLayer.Features.Clear(); highlightLayer.Features.Add(identifiedFeature); Map1.Refresh("HighlightOverlay"); } }
private void Map1_MapSingleClick(object sender, MapClickEventArgs e) { Feature identifiedFeature = IdentifyHelper.Identify(dataLayer, e.WorldCoordinate, Map1.CurrentScale, Map1.MapUnit).FirstOrDefault(); if (identifiedFeature != null) { double distanceInMeter = ((GeoLinearBase)identifiedFeature.Geometry).GetLength(); identifiedFeature.FieldValues.Add("Distance", $"{distanceInMeter:N2} m"); MemoryLayer highlightLayer = Map1.FindLayer <MemoryLayer>("HighlightLayer"); highlightLayer.Features.Clear(); highlightLayer.Features.Add(identifiedFeature); Map1.Refresh("HighlightOverlay"); } }
private void Map1_MapSingleClick(object sender, MapClickEventArgs e) { Feature identifiedFeature = IdentifyHelper.Identify(dataLayer, e.WorldCoordinate, Map1.CurrentScale, Map1.MapUnit).FirstOrDefault(); if (identifiedFeature != null) { MemoryLayer highlightLayer = Map1.FindLayer <MemoryLayer>("HighlightLayer"); highlightLayer.Features.Clear(); highlightLayer.Features.Add(identifiedFeature); WktTextBox.Text = identifiedFeature.ToWkt(); WkbTextBox.Text = Convert.ToBase64String(identifiedFeature.ToWkb()); Map1.Refresh("HighlightOverlay"); } }
private void Map1_MapClick(object sender, MapClickEventArgs e) { // We added a ShapefileLayer in the Loaded event, // it's default name is the name of the shapefile. // so here, we could find the layer back by the shapefile name without extension. FeatureLayer featureLayer = Map1.FindLayer <FeatureLayer>("countries-900913"); Feature identifiedFeature = IdentifyHelper.Identify(featureLayer, e.WorldCoordinate, Map1.CurrentScale, Map1.MapUnit).FirstOrDefault(); Map1.Placements.Clear(); if (identifiedFeature != null) { Popup popup = new Popup(); popup.Location = e.WorldCoordinate; popup.Content = new Label { Content = identifiedFeature.FieldValues["LONG_NAME"] }; Map1.Placements.Add(popup); } }
private void Map1_MapSingleClick(object sender, MapClickEventArgs e) { Feature identifiedFeature = IdentifyHelper.Identify(dataLayer, e.WorldCoordinate, Map1.CurrentScale, Map1.MapUnit).FirstOrDefault(); if (identifiedFeature != null) { MemoryLayer highlightLayer = Map1.FindLayer <MemoryLayer>("HighlightLayer"); highlightLayer.Features.Clear(); highlightLayer.Features.Add(identifiedFeature); GeoBound identifiedBound = identifiedFeature.GetBound(); highlightLayer.Features.Add(new Feature(new GeoLine(identifiedBound.GetVertices()))); GeoPoint identifiedCenter = identifiedBound.GetCentroid(); highlightLayer.Features.Add(new Feature(identifiedCenter)); Map1.Refresh("HighlightOverlay"); } }
public async Task Identify(Point position, MapPoint location, LayerCollection layerCollection) { try { IsIdentifying = true; AnchorMapPoint = location; IdentifyItems = ParseIdentifyResults(await IdentifyHelper.Identify(Controller, position, location, layerCollection)); SelectedItem = null; ShowDetailView = false; if (Count == 1) { ShowDetailView = true; SelectedItem = IdentifyItems.First(); } if (!WebMapVM.Map.Layers.Contains(IdentifyLayer)) { AddGraphicsLayer(IdentifyLayer); } } finally { IsIdentifying = false; } }