private void DisplayMap_Load(object sender, EventArgs e) { winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean); winformsMap1.MapUnit = GeographyUnit.DecimalDegree; TiledWmsLayer tiledWmsLayer = AddTileLayer(); LayerOverlay staticOverlay = GetStaticLayer(); staticOverlay.Layers.Add("SimpleWmsLayerPlugin", tiledWmsLayer); winformsMap1.Overlays.Add(staticOverlay); SetupInitialIconDisplay(); } private TiledWmsLayer AddTileLayer() { Collection onsiteServers = new Collection(); onsiteServers.Add(new Uri("http://wmssamples.thinkgeo.com/WmsServer.aspx")); TiledWmsLayer tiledWmsLayer = new TiledWmsLayer(onsiteServers); tiledWmsLayer.Open(); foreach (var item in tiledWmsLayer.GetServerLayerNames()) { tiledWmsLayer.ActiveLayerNames.Add(item); } foreach (var item in tiledWmsLayer.GetServerStyleNames()) { tiledWmsLayer.ActiveStyleNames.Add(item); } return tiledWmsLayer; } private static LayerOverlay GetStaticLayer() { LayerOverlay staticOverlay = new LayerOverlay() { IsBase = true }; return staticOverlay; } private void SetupInitialIconDisplay() { SimpleMarkerOverlay markerOverlay = new SimpleMarkerOverlay() { IsBase = false, MapControl = winformsMap1 }; winformsMap1.Overlays.Add("IconMarkerOverlay", markerOverlay); DrawMarkers(markerOverlay); } private void DrawMarkers(SimpleMarkerOverlay markeroverlay) { Random random = new Random(); for (int i = 0; i < 10; i++) { Marker marker = new Marker(random.Next(-100, 100), random.Next(-90, 90)) { Name = i.ToString() }; marker.Image = Properties.Resources.AQUA; marker.Tag = "state"; marker.ToolTipText = "tool tip text"; SetMarkerProperties(marker); markeroverlay.Markers.Add(i.ToString(), marker); } SetAllMarkerZOrder(); winformsMap1.Refresh(); } private static void SetMarkerProperties(Marker marker) { marker.Width = 20; marker.Height = 20; marker.XOffset = 10; marker.YOffset = 10; } private void SetAllMarkerZOrder() { MarkerOverlaySortByDisplayState(); } private SimpleMarkerOverlay MarkerOverlaySortByDisplayState() { GeoCollection tmpSortedMarkers = new GeoCollection(); SimpleMarkerOverlay markerOverlay = (SimpleMarkerOverlay)winformsMap1.Overlays["IconMarkerOverlay"]; foreach (Marker item in markerOverlay.Markers) { tmpSortedMarkers.Add(item.Name, item); } markerOverlay.Markers.Clear(); foreach (Marker item in tmpSortedMarkers) { markerOverlay.Markers.Add(item.Name, item); } return markerOverlay; }