using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using ThinkGeo.MapSuite.WpfDesktopEdition; using ThinkGeo.MapSuite.Core; using System.Collections.ObjectModel; namespace Simplepointshape { public class Custom_PopupOverlay : PopupOverlay { protected override RectangleShape GetBoundingBoxCore() { if (Popups.Count > 0) { return base.GetBoundingBoxCore(); } else { return (new RectangleShape(-128.0, 50.0, -60.0, 22.0)); } } } public class pointst { public double lat {get;set;} public double lon { get; set; } public string tagtext { get; set; } } public partial class MainWindow : Window { InMemoryFeatureLayer testlayer = new InMemoryFeatureLayer(); public MainWindow() { InitializeComponent(); Draw(); } private void Draw() { PopupOverlay _PopupOverlay; WorldMapKitWmsWpfOverlay worldMapKitOverlay = null; worldMapKitOverlay = new WorldMapKitWmsWpfOverlay(); worldMapKitOverlay.Projection = WorldMapKitProjection.DecimalDegrees; Map.Overlays.Add(worldMapKitOverlay); Map.MouseEnter += new MouseEventHandler(_MapMouseEnter); _PopupOverlay = new Custom_PopupOverlay(); // PopupOverlay(); Map.Overlays.Add(_PopupOverlay); GeoLinearGradientBrush geoBrush = null; GeoColor stColor = GeoColor.FromArgb(100, GeoColor.StandardColors.Green); GeoColor endColor = GeoColor.FromArgb(10, GeoColor.StandardColors.LightCoral); geoBrush = new GeoLinearGradientBrush(stColor, endColor, GeoLinearGradientDirection.UpperLeftToLowerRight); geoBrush.WrapMode = GeoWrapMode.TileFlipXY; testlayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.Advanced.FillCustomBrush = geoBrush; testlayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateMaskTextStyle("Label", new GeoFont("Arial", 10), new GeoSolidBrush(GeoColor.SimpleColors.Black), new AreaStyle(new GeoPen(GeoColor.StandardColors.Black), new GeoSolidBrush(GeoColor.StandardColors.LightGoldenrodYellow)), 10, 0); testlayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.DarkBlue; testlayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen = new GeoPen(GeoColor.FromArgb(200, GeoColor.StandardColors.Green), 1); testlayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.SymbolPen = new GeoPen(GeoColor.FromArgb(255, GeoColor.StandardColors.Green), 8); testlayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; testlayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.OverlappingRule = LabelOverlappingRule.NoOverlapping; testlayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.Font = new GeoFont("Arial", 8, DrawingFontStyles.Bold); testlayer.Open(); testlayer.Columns.Add(new FeatureSourceColumn("Label")); testlayer.Close(); double centerX = -75.16058350000; double centerY = 39.91750340000; pointst pt = new pointst(); pt.lat = centerY; pt.lon = centerX; pt.tagtext = "ONE"; PointShape ptCenter = new PointShape(centerX, centerY); LayerOverlay dynamicOverlay = new LayerOverlay(); //circleShape = new EllipseShape(ptCenter, dRadius,GeographyUnit.DecimalDegree,DistanceUnit.Meter); Feature featShape = new Feature(ptCenter); featShape.ColumnValues.Add("Label", "mypoint"); featShape.Tag = pt; testlayer.InternalFeatures.Add("1", featShape); ptCenter.Id = "1"; ptCenter.Tag = "1"; dynamicOverlay.Layers.Add(testlayer); Map.Overlays.Add(dynamicOverlay); } private void _MapMouseEnter(object sender, MouseEventArgs e) { PointShape ptShape = null; ptShape = Map.ToWorldCoordinate(e.GetPosition(Map)); bool flag = false; Collection selectedpoint = null; testlayer.Open(); selectedpoint = testlayer.QueryTools.GetFeaturesContaining(ptShape, ReturningColumnsType.AllColumns); double disStop = Double.MaxValue; if (selectedpoint.Count == 0) { selectedpoint = testlayer.QueryTools.GetFeaturesContaining(ptShape, ReturningColumnsType.AllColumns); flag = true; } if (selectedpoint.Count > 1) { BaseShape baseShape = selectedpoint[0].GetShape(); PointShape ptStopShape = baseShape as PointShape; if (null != ptStopShape) { disStop = ptShape.GetDistanceTo(ptStopShape, GeographyUnit.DecimalDegree, DistanceUnit.Meter); } } if (flag == true) { Popup popup = new Popup(ptShape); StringBuilder sbinfo = new StringBuilder(); if (selectedpoint.Count >= 1) { object objCust = selectedpoint[0].Tag; pointst objtest = ((pointst)objCust); sbinfo.Append("Custom Data from query feature:"); sbinfo.Append(objtest.tagtext); } } } public static RectangleShape GetUSExtent() { RectangleShape usExtent = new RectangleShape(-128.0, 50.0, -60.0, 22.0); return usExtent; } } }