Example #1
0
        private Map InitializeMap()
        {
            Map Map1 = new Map("Map1");

            Map1.MapUnit                              = GeographyUnit.Meter;
            Map1.ZoomLevelSet                         = new ThinkGeoCloudMapsZoomLevelSet();
            Map1.Width                                = new System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage);
            Map1.Height                               = new System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage);
            Map1.CurrentExtent                        = new RectangleShape(-10785241.6495495, 3916508.33762434, -10778744.5183967, 3912187.74540771);
            Map1.MapTools.MiniMap.Enabled             = true;
            Map1.MapTools.OverlaySwitcher.Enabled     = true;
            Map1.EditOverlay.EditSettings.IsResizable = false;

            // Please input your ThinkGeo Cloud API Key to enable the background map.
            ThinkGeoCloudRasterMapsOverlay ThinkGeoCloudMapsLight = new ThinkGeoCloudRasterMapsOverlay("ThinkGeo Cloud API Key")
            {
                Name    = "ThinkGeo Cloud Maps Light",
                MapType = ThinkGeoCloudRasterMapsMapType.Light
            };

            Map1.CustomOverlays.Add(ThinkGeoCloudMapsLight);

            ThinkGeoCloudRasterMapsOverlay ThinkGeoCloudMapsAerial = new ThinkGeoCloudRasterMapsOverlay("ThinkGeo Cloud API Key")
            {
                Name    = "ThinkGeo Cloud Maps Aerial",
                MapType = ThinkGeoCloudRasterMapsMapType.Aerial
            };

            Map1.CustomOverlays.Add(ThinkGeoCloudMapsAerial);

            ThinkGeoCloudRasterMapsOverlay ThinkGeoCloudMapsHybrid = new ThinkGeoCloudRasterMapsOverlay("ThinkGeo Cloud API Key")
            {
                Name    = "ThinkGeo Cloud Maps Hybrid",
                MapType = ThinkGeoCloudRasterMapsMapType.Hybrid
            };

            Map1.CustomOverlays.Add(ThinkGeoCloudMapsHybrid);

            OpenStreetMapOverlay openStreetMapOverlay = new OpenStreetMapOverlay("Open Street Map");

            Map1.CustomOverlays.Add(openStreetMapOverlay);

            // Add spatial fences
            AddSpatialFenceOverlay(Map1);

            // Add vehicles.
            AddVehicleMarkerOverlay(Map1);

            // Add vehicles position history.
            AddVehicleHistoryMarkerOverlay(Map1);

            // Add scale bar
            ScaleBarAdornmentLayer scaleBarAdormentLayer = new ScaleBarAdornmentLayer();

            scaleBarAdormentLayer.XOffsetInPixel = 10;
            scaleBarAdormentLayer.UnitFamily     = UnitSystem.Metric;
            //Map1.AdornmentOverlay.Layers.Add(scaleBarAdormentLayer);

            return(Map1);
        }
Example #2
0
        private void InitializeMap()
        {
            map.MapUnit = GeographyUnit.Meter;
            WorldStreetsAndImageryOverlay worldOverlay = new WorldStreetsAndImageryOverlay();

            worldOverlay.IsVisible  = false;
            worldOverlay.Projection = WorldStreetsAndImageryProjection.SphericalMercator;
            worldOverlay.MapType    = WorldStreetsAndImageryMapType.Road;
            map.Overlays.Add("World Kit Map", worldOverlay);

            GoogleMapsOverlay googleMapOverlay = new GoogleMapsOverlay();

            googleMapOverlay.IsVisible = false;
            map.Overlays.Add("Google Maps", googleMapOverlay);

            BingMapsOverlay bingMapOverlay = new BingMapsOverlay();

            bingMapOverlay.ApplicationId = ""; //Please set your application id.
            bingMapOverlay.IsVisible     = false;
            map.Overlays.Add("Bing Maps", bingMapOverlay);

            OpenStreetMapOverlay osmOverlay = new OpenStreetMapOverlay();

            osmOverlay.IsVisible = false;
            map.Overlays.Add("Open Street Map", osmOverlay);
        }
Example #3
0
        private Map InitializeMap()
        {
            Map Map1 = new Map("Map1");

            Map1.MapUnit                              = GeographyUnit.Meter;
            Map1.Width                                = new System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage);
            Map1.Height                               = new System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage);
            Map1.CurrentExtent                        = new RectangleShape(-10785241.6495495, 3916508.33762434, -10778744.5183967, 3912187.74540771);
            Map1.MapTools.MiniMap.Enabled             = true;
            Map1.MapTools.OverlaySwitcher.Enabled     = true;
            Map1.EditOverlay.EditSettings.IsResizable = false;

            // base map layer
            WorldStreetsAndImageryOverlay worldMapKitRoadOverlay = new WorldStreetsAndImageryOverlay("World Map Kit Road");

            worldMapKitRoadOverlay.Projection = WorldStreetsAndImageryProjection.SphericalMercator;
            worldMapKitRoadOverlay.MapType    = WorldStreetsAndImageryMapType.Road;
            Map1.CustomOverlays.Add(worldMapKitRoadOverlay);

            WorldStreetsAndImageryOverlay worldMapKitAerialOverlay = new WorldStreetsAndImageryOverlay("World Map Kit Aerial");

            worldMapKitAerialOverlay.Projection = WorldStreetsAndImageryProjection.SphericalMercator;
            worldMapKitAerialOverlay.MapType    = WorldStreetsAndImageryMapType.Aerial;
            Map1.CustomOverlays.Add(worldMapKitAerialOverlay);

            WorldStreetsAndImageryOverlay worldMapKitAerialWithLabelsOverlay = new WorldStreetsAndImageryOverlay("World Map Kit Aerial With Labels");

            worldMapKitAerialWithLabelsOverlay.Projection = WorldStreetsAndImageryProjection.SphericalMercator;
            worldMapKitAerialWithLabelsOverlay.MapType    = WorldStreetsAndImageryMapType.AerialWithLabels;
            Map1.CustomOverlays.Add(worldMapKitAerialWithLabelsOverlay);

            OpenStreetMapOverlay openStreetMapOverlay = new OpenStreetMapOverlay("Open Street Map");

            Map1.CustomOverlays.Add(openStreetMapOverlay);

            // Add spatial fences
            AddSpatialFenceOverlay(Map1);

            // Add vehicles.
            AddVehicleMarkerOverlay(Map1);

            // Add vehicles position history.
            AddVehicleHistoryMarkerOverlay(Map1);

            // Add scale bar
            ScaleBarAdornmentLayer scaleBarAdormentLayer = new ScaleBarAdornmentLayer();

            scaleBarAdormentLayer.XOffsetInPixel = 10;
            scaleBarAdormentLayer.UnitFamily     = UnitSystem.Metric;
            //Map1.AdornmentOverlay.Layers.Add(scaleBarAdormentLayer);

            return(Map1);
        }
Example #4
0
        public static OpenStreetMapOverlay AddOpenStreetMapOverlay(GisEditorWpfMap map)
        {
            OpenStreetMapOverlay osmOverlay = new OpenStreetMapOverlay();

            osmOverlay.TileType             = TileType.HybridTile;
            osmOverlay.Name                 = "OpenStreetMap";
            osmOverlay.DrawingExceptionMode = DrawingExceptionMode.DrawException;
            osmOverlay.DrawingException    += new EventHandler <DrawingExceptionTileOverlayEventArgs>(OsmOverlay_DrawingException);
            osmOverlay.RefreshCache();
            BaseMapsHelper.AddOverlayInGoogleProjection(osmOverlay, map);
            return(osmOverlay);
        }
Example #5
0
        private static MenuItem GetChangeTransparencyItem(double transparencyPa)
        {
            var transparencyMenuItem = new MenuItem();

            transparencyMenuItem.Header      = transparencyPa + " %";
            transparencyMenuItem.IsCheckable = true;
            double value = transparencyPa / 100;

            transparencyMenuItem.Tag = value;

            transparencyMenuItem.Click += (s, e) =>
            {
                var selectedMenuItem = (MenuItem)s;
                var transparency     = Convert.ToDouble(selectedMenuItem.Tag);
                if (GisEditor.LayerListManager.SelectedLayerListItem == null)
                {
                    return;
                }


                BingMapsOverlay       bingMapsOverlay       = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as BingMapsOverlay;
                OpenStreetMapOverlay  openStreetMapOverlay  = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as OpenStreetMapOverlay;
                WorldMapKitMapOverlay worldMapKitMapOverlay = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as WorldMapKitMapOverlay;

                if (bingMapsOverlay != null && bingMapsOverlay.OverlayCanvas.Opacity != transparency)
                {
                    bingMapsOverlay.OverlayCanvas.Opacity = transparency;
                    bingMapsOverlay.Invalidate();
                }
                else if (openStreetMapOverlay != null && openStreetMapOverlay.OverlayCanvas.Opacity != transparency)
                {
                    openStreetMapOverlay.OverlayCanvas.Opacity = transparency;
                    openStreetMapOverlay.Invalidate();
                }
                else if (worldMapKitMapOverlay != null && worldMapKitMapOverlay.OverlayCanvas.Opacity != transparency)
                {
                    worldMapKitMapOverlay.OverlayCanvas.Opacity = transparency;
                    worldMapKitMapOverlay.Invalidate();
                }


                foreach (MenuItem item in ((MenuItem)selectedMenuItem.Parent).Items)
                {
                    if (!item.Equals(selectedMenuItem))
                    {
                        item.IsChecked = false;
                    }
                }
            };
            return(transparencyMenuItem);
        }
        private void TestForm_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit = GeographyUnit.Meter;
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);

            OpenStreetMapOverlay osmOvelerlay = new OpenStreetMapOverlay();

            osmOvelerlay.TileCache = new FileBitmapTileCache(@"C:\temp\OpenStreetMapLayerCache1");

            winformsMap1.Overlays.Add(osmOvelerlay);

            winformsMap1.CurrentExtent = new RectangleShape(-4352400.53526627, 8867834.11959479, 10425951.3896003, -2890780.54967516);
            winformsMap1.Refresh();
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.DisplayASimpleMap);

            OpenStreetMapOverlay osmOvelerlay = new OpenStreetMapOverlay();

            androidMap               = FindViewById <MapView>(Resource.Id.androidmap);
            androidMap.MapUnit       = GeographyUnit.Meter;
            androidMap.ZoomLevelSet  = new OpenStreetMapsZoomLevelSet();
            androidMap.CurrentExtent = osmOvelerlay.GetBoundingBox();
            androidMap.Overlays.Add(osmOvelerlay);

            SampleViewHelper.InitializeInstruction(this, FindViewById <RelativeLayout>(Resource.Id.MainLayout), GetType());
        }
Example #8
0
        private void TestForm_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit = GeographyUnit.Meter;
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.Snow);

            //Background map with Open Street Map.
            OpenStreetMapOverlay openStreetMapOverlay = new OpenStreetMapOverlay();

            winformsMap1.Overlays.Add(openStreetMapOverlay);

            //Applies class break style to show sample points of pH level of a field.
            ClassBreakStyle classBreakStyle = new ClassBreakStyle("PH");
            int             Alpha           = 180;
            int             symbolSize      = 10;

            classBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.SimpleColors.Transparent), symbolSize)));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(6.2, new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(Alpha, 255, 0, 0)), symbolSize)));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(6.83, new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(Alpha, 255, 128, 0)), symbolSize)));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(7.0, new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(Alpha, 245, 210, 10)), symbolSize)));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(7.08, new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(Alpha, 225, 255, 0)), symbolSize)));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(7.15, new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(Alpha, 224, 251, 132)), symbolSize)));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(7.21, new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(Alpha, 128, 255, 128)), symbolSize)));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(7.54, new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(Alpha, 0, 255, 0)), symbolSize)));

            ShapeFileFeatureLayer samplesLayer = new ShapeFileFeatureLayer(@"..\..\data\sample_ph_2.shp");

            samplesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);
            samplesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay gridOverlay = new LayerOverlay();

            gridOverlay.Layers.Add("GridFeatureLayer", samplesLayer);
            winformsMap1.Overlays.Add("GridFeatureOverlay", gridOverlay);

            samplesLayer.Open();
            winformsMap1.CurrentExtent = samplesLayer.GetBoundingBox();
            samplesLayer.Close();

            winformsMap1.Refresh();
        }
Example #9
0
        private void AddBaseMapLayers(Map Map1)
        {
            WorldStreetsAndImageryOverlay worldMapKitRoadOverlay = new WorldStreetsAndImageryOverlay("World Map Kit Road");

            worldMapKitRoadOverlay.Projection = WorldStreetsAndImageryProjection.SphericalMercator;
            worldMapKitRoadOverlay.MapType    = WorldStreetsAndImageryMapType.Road;
            Map1.CustomOverlays.Add(worldMapKitRoadOverlay);

            WorldStreetsAndImageryOverlay worldMapKitAerialOverlay = new WorldStreetsAndImageryOverlay("World Map Kit Aerial");

            worldMapKitAerialOverlay.Projection = WorldStreetsAndImageryProjection.SphericalMercator;
            worldMapKitAerialOverlay.MapType    = WorldStreetsAndImageryMapType.Aerial;
            Map1.CustomOverlays.Add(worldMapKitAerialOverlay);

            WorldStreetsAndImageryOverlay worldMapKitAerialWithLabelsOverlay = new WorldStreetsAndImageryOverlay("World Map Kit Aerial With Labels");

            worldMapKitAerialWithLabelsOverlay.Projection = WorldStreetsAndImageryProjection.SphericalMercator;
            worldMapKitAerialWithLabelsOverlay.MapType    = WorldStreetsAndImageryMapType.AerialWithLabels;
            Map1.CustomOverlays.Add(worldMapKitAerialWithLabelsOverlay);

            OpenStreetMapOverlay openStreetMapOverlay = new OpenStreetMapOverlay("Open Street Map");

            Map1.CustomOverlays.Add(openStreetMapOverlay);
        }
Example #10
0
        private void InitializeAndroidMap()
        {
            string          baseFolder        = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
            string          cachePathFilename = Path.Combine(baseFolder, "MapSuiteTileCaches/SampleCaches.db");
            Proj4Projection proj4             = Global.GetWgs84ToMercatorProjection();

            // WMK
            WorldMapKitOverlay wmkOverlay = new WorldMapKitOverlay();

            wmkOverlay.Projection = ThinkGeo.MapSuite.Android.WorldMapKitProjection.SphericalMercator;

            // OSM
            OpenStreetMapOverlay osmOverlay = new OpenStreetMapOverlay();

            osmOverlay.TileCache = new SqliteBitmapTileCache(cachePathFilename, "OSMSphericalMercator");
            osmOverlay.IsVisible = false;

            // Bing - Aerial
            BingMapsOverlay bingMapsAerialOverlay = new BingMapsOverlay();

            bingMapsAerialOverlay.IsVisible = false;
            bingMapsAerialOverlay.MapType   = ThinkGeo.MapSuite.Android.BingMapsMapType.AerialWithLabels;
            bingMapsAerialOverlay.TileCache = new SqliteBitmapTileCache(cachePathFilename, "BingAerialWithLabels");

            // Bing - Road
            BingMapsOverlay bingMapsRoadOverlay = new BingMapsOverlay();

            bingMapsRoadOverlay.IsVisible = false;
            bingMapsRoadOverlay.MapType   = ThinkGeo.MapSuite.Android.BingMapsMapType.Road;
            bingMapsRoadOverlay.TileCache = new SqliteBitmapTileCache(cachePathFilename, "BingRoad");

            // Earthquake points
            earthquakePointLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath("usEarthquake.shp"));
            earthquakePointLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(PointStyles.CreateSimpleCircleStyle(GeoColor.SimpleColors.Red, 5, GeoColor.SimpleColors.White, 1));
            earthquakePointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            earthquakePointLayer.FeatureSource.Projection = proj4;

            ShapeFileFeatureSource earthquakeHeatFeatureSource = new ShapeFileFeatureSource(SampleHelper.GetDataPath("usEarthquake_Simplify.shp"));

            earthquakeHeatFeatureSource.Projection = proj4;

            earthquakeHeatLayer                 = new HeatLayer(earthquakeHeatFeatureSource);
            earthquakeHeatLayer.HeatStyle       = new HeatStyle(10, 75, DistanceUnit.Kilometer);
            earthquakeHeatLayer.HeatStyle.Alpha = 180;
            earthquakeHeatLayer.IsVisible       = false;

            earthquakeOverlay = new LayerOverlay();
            earthquakeOverlay.Layers.Add(Global.EarthquakePointLayerKey, earthquakePointLayer);
            earthquakeOverlay.Layers.Add(Global.EarthquakeHeatLayerKey, earthquakeHeatLayer);

            // Highlighted points
            selectedMarkerLayer = new InMemoryFeatureLayer();
            selectedMarkerLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = PointStyles.CreateSimpleCircleStyle(GeoColor.SimpleColors.Orange, 8, GeoColor.SimpleColors.White, 2);
            selectedMarkerLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            PointStyle highLightMarkerStyle = new PointStyle();

            highLightMarkerStyle.CustomPointStyles.Add(PointStyles.CreateSimpleCircleStyle(GeoColor.FromArgb(50, GeoColor.SimpleColors.Blue), 20, GeoColor.SimpleColors.LightBlue, 1));
            highLightMarkerStyle.CustomPointStyles.Add(PointStyles.CreateSimpleCircleStyle(GeoColor.FromArgb(255, 0, 122, 255), 10, GeoColor.SimpleColors.White, 2));

            highlightMarkerLayer = new InMemoryFeatureLayer();
            highlightMarkerLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = highLightMarkerStyle;
            highlightMarkerLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            highlightOverlay = new LayerOverlay();
            highlightOverlay.Layers.Add(Global.SelectMarkerLayerKey, selectedMarkerLayer);
            highlightOverlay.Layers.Add(Global.HighlightMarkerLayerKey, highlightMarkerLayer);

            // Maps
            Global.MapView         = FindViewById <MapView>(Resource.Id.androidMap);
            Global.MapView.MapUnit = GeographyUnit.Meter;
            Global.MapView.MapTools.ZoomMapTool.Visibility = ViewStates.Invisible;
            Global.MapView.ZoomLevelSet  = new ZoomLevelSet();
            Global.MapView.CurrentExtent = new RectangleShape(-19062735.6816748, 9273256.52450252, -5746827.16371793, 2673516.56066139);
            Global.MapView.SetBackgroundColor(new Android.Graphics.Color(255, 244, 242, 238));

            Global.MapView.Overlays.Add(Global.WorldMapKitOverlayKey, wmkOverlay);
            Global.MapView.Overlays.Add(Global.OpenStreetMapOverlayKey, osmOverlay);
            Global.MapView.Overlays.Add(Global.BingMapsAerialOverlayKey, bingMapsAerialOverlay);
            Global.MapView.Overlays.Add(Global.BingMapsRoadOverlayKey, bingMapsRoadOverlay);
            Global.MapView.Overlays.Add(Global.EarthquakeOverlayKey, earthquakeOverlay);
            Global.MapView.Overlays.Add(Global.HighlightOverlayKey, highlightOverlay);

            Global.MapView.TrackOverlay.TrackShapeLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Clear();
            Global.MapView.TrackOverlay.TrackShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.FromArgb(80, GeoColor.SimpleColors.LightGreen), 8);
            Global.MapView.TrackOverlay.TrackShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle  = LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.White, 3, true);
            Global.MapView.TrackOverlay.TrackShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle  = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(80, GeoColor.SimpleColors.LightGreen), GeoColor.SimpleColors.White, 2);
            Global.MapView.TrackOverlay.TrackEnded += TrackOverlay_TrackEnded;
        }
        private void InitializeOverlays()
        {
            string cacheFolder = Path.Combine(Path.GetTempPath(), "TileCache");

            WorldMapKitWmsWpfOverlay worldMapKitRoadOverlay = new WorldMapKitWmsWpfOverlay();
            worldMapKitRoadOverlay.Name = Resources.WorldMapKitOverlayRoadName;
            worldMapKitRoadOverlay.TileHeight = 512;
            worldMapKitRoadOverlay.TileWidth = 512;
            worldMapKitRoadOverlay.Projection = WorldMapKitProjection.SphericalMercator;
            worldMapKitRoadOverlay.MapType = WorldMapKitMapType.Road;
            worldMapKitRoadOverlay.IsVisible = true;
            worldMapKitRoadOverlay.TileCache = new FileBitmapTileCache(cacheFolder, Resources.WorldMapKitOverlayRoadName);
            mapControl.Overlays.Add(worldMapKitRoadOverlay);

            WorldMapKitWmsWpfOverlay worldMapKitAerialOverlay = new WorldMapKitWmsWpfOverlay();
            worldMapKitAerialOverlay.Name = Resources.WorldMapKitOverlayAerialName;
            worldMapKitAerialOverlay.TileHeight = 512;
            worldMapKitAerialOverlay.TileWidth = 512;
            worldMapKitAerialOverlay.Projection = WorldMapKitProjection.SphericalMercator;
            worldMapKitAerialOverlay.MapType = WorldMapKitMapType.Aerial;
            worldMapKitAerialOverlay.IsVisible = false;
            worldMapKitAerialOverlay.TileCache = new FileBitmapTileCache(cacheFolder, Resources.WorldMapKitOverlayAerialName);
            mapControl.Overlays.Add(worldMapKitAerialOverlay);

            WorldMapKitWmsWpfOverlay worldMapKitAerialWithLabelsOverlay = new WorldMapKitWmsWpfOverlay();
            worldMapKitAerialWithLabelsOverlay.Name = Resources.WorldMapKitOverlayAerialWithLabelsName;
            worldMapKitAerialWithLabelsOverlay.TileHeight = 512;
            worldMapKitAerialWithLabelsOverlay.TileWidth = 512;
            worldMapKitAerialWithLabelsOverlay.Projection = WorldMapKitProjection.SphericalMercator;
            worldMapKitAerialWithLabelsOverlay.MapType = WorldMapKitMapType.AerialWithLabels;
            worldMapKitAerialWithLabelsOverlay.IsVisible = false;
            worldMapKitAerialWithLabelsOverlay.TileCache = new FileBitmapTileCache(cacheFolder, Resources.WorldMapKitOverlayAerialWithLabelsName);
            mapControl.Overlays.Add(worldMapKitAerialWithLabelsOverlay);

            OpenStreetMapOverlay openStreetMapOverlay = new OpenStreetMapOverlay();
            openStreetMapOverlay.Name = Resources.OpenStreetMapName;
            openStreetMapOverlay.TileHeight = 512;
            openStreetMapOverlay.TileWidth = 512;
            openStreetMapOverlay.IsVisible = false;
            openStreetMapOverlay.TileCache = new FileBitmapTileCache(cacheFolder, "OpenStreetMap");
            mapControl.Overlays.Add(Resources.OpenStreetMapKey, openStreetMapOverlay);

            BingMapsOverlay bingMapsAerialOverlay = new BingMapsOverlay();
            bingMapsAerialOverlay.Name = Resources.BingMapsAerialMapName;
            bingMapsAerialOverlay.TileHeight = 512;
            bingMapsAerialOverlay.TileWidth = 512;
            bingMapsAerialOverlay.MapType = BingMapsMapType.Aerial;
            bingMapsAerialOverlay.IsVisible = false;
            bingMapsAerialOverlay.TileCache = new FileBitmapTileCache(cacheFolder, "BingMapsAerial");
            mapControl.Overlays.Add(Resources.BingAerialKey, bingMapsAerialOverlay);

            BingMapsOverlay bingMapsRoadOverlay = new BingMapsOverlay();
            bingMapsRoadOverlay.Name = Resources.BingMapsRoadMapName;
            bingMapsRoadOverlay.TileHeight = 512;
            bingMapsRoadOverlay.TileWidth = 512;
            bingMapsRoadOverlay.MapType = BingMapsMapType.Road;
            bingMapsRoadOverlay.IsVisible = false;
            bingMapsRoadOverlay.TileCache = new FileBitmapTileCache(cacheFolder, "BingMapsRoad");
            mapControl.Overlays.Add(Resources.BingRoadKey, bingMapsRoadOverlay);

            InMemoryFeatureLayer spatialFenceLayer = new InMemoryFeatureLayer();
            spatialFenceLayer.Open();
            spatialFenceLayer.Columns.Add(new FeatureSourceColumn(Resources.RestrictedName, "Charater", 10));
            spatialFenceLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoPen(GeoColor.FromArgb(255, 204, 204, 204), 2), new GeoSolidBrush(GeoColor.FromArgb(112, 255, 0, 0)));
            spatialFenceLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle(Resources.RestrictedName, "Arial", 12, DrawingFontStyles.Regular, GeoColor.StandardColors.Black, GeoColor.SimpleColors.White, 2);
            spatialFenceLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay spatialFenceOverlay = new LayerOverlay();
            spatialFenceOverlay.TileType = TileType.SingleTile;
            spatialFenceOverlay.Name = Resources.SpatialFenceOverlayName;
            spatialFenceOverlay.Layers.Add(Resources.SpatialFenceLayerName, spatialFenceLayer);
            mapControl.Overlays.Add(Resources.SpatialFenceOverlayName, spatialFenceOverlay);

            LayerOverlay traceOverlay = new LayerOverlay();
            traceOverlay.Name = Resources.TraceOverlayName;
            traceOverlay.TileType = TileType.SingleTile;
            mapControl.Overlays.Add(Resources.TraceOverlayName, traceOverlay);

            mapControl.Overlays.Add(Resources.PopupOverlayName, new PopupOverlay { Name = Resources.PopupOverlayName });

            ScaleBarAdornmentLayer scaleBarAdormentLayer = new ScaleBarAdornmentLayer();
            scaleBarAdormentLayer.UnitFamily = UnitSystem.Metric;
            mapControl.AdornmentOverlay.Layers.Add(Resources.ScaleBarName, scaleBarAdormentLayer);
        }
        private void InitializeOverlays()
        {
            string cacheFolder = Path.Combine(Path.GetTempPath(), "TileCache");

            WorldMapKitWmsWpfOverlay worldMapKitRoadOverlay = new WorldMapKitWmsWpfOverlay();

            worldMapKitRoadOverlay.Name       = Resources.WorldMapKitOverlayRoadName;
            worldMapKitRoadOverlay.TileHeight = 512;
            worldMapKitRoadOverlay.TileWidth  = 512;
            worldMapKitRoadOverlay.Projection = WorldMapKitProjection.SphericalMercator;
            worldMapKitRoadOverlay.MapType    = WorldMapKitMapType.Road;
            worldMapKitRoadOverlay.IsVisible  = true;
            worldMapKitRoadOverlay.TileCache  = new FileBitmapTileCache(cacheFolder, Resources.WorldMapKitOverlayRoadName);
            mapControl.Overlays.Add(worldMapKitRoadOverlay);

            WorldMapKitWmsWpfOverlay worldMapKitAerialOverlay = new WorldMapKitWmsWpfOverlay();

            worldMapKitAerialOverlay.Name       = Resources.WorldMapKitOverlayAerialName;
            worldMapKitAerialOverlay.TileHeight = 512;
            worldMapKitAerialOverlay.TileWidth  = 512;
            worldMapKitAerialOverlay.Projection = WorldMapKitProjection.SphericalMercator;
            worldMapKitAerialOverlay.MapType    = WorldMapKitMapType.Aerial;
            worldMapKitAerialOverlay.IsVisible  = false;
            worldMapKitAerialOverlay.TileCache  = new FileBitmapTileCache(cacheFolder, Resources.WorldMapKitOverlayAerialName);
            mapControl.Overlays.Add(worldMapKitAerialOverlay);

            WorldMapKitWmsWpfOverlay worldMapKitAerialWithLabelsOverlay = new WorldMapKitWmsWpfOverlay();

            worldMapKitAerialWithLabelsOverlay.Name       = Resources.WorldMapKitOverlayAerialWithLabelsName;
            worldMapKitAerialWithLabelsOverlay.TileHeight = 512;
            worldMapKitAerialWithLabelsOverlay.TileWidth  = 512;
            worldMapKitAerialWithLabelsOverlay.Projection = WorldMapKitProjection.SphericalMercator;
            worldMapKitAerialWithLabelsOverlay.MapType    = WorldMapKitMapType.AerialWithLabels;
            worldMapKitAerialWithLabelsOverlay.IsVisible  = false;
            worldMapKitAerialWithLabelsOverlay.TileCache  = new FileBitmapTileCache(cacheFolder, Resources.WorldMapKitOverlayAerialWithLabelsName);
            mapControl.Overlays.Add(worldMapKitAerialWithLabelsOverlay);

            OpenStreetMapOverlay openStreetMapOverlay = new OpenStreetMapOverlay();

            openStreetMapOverlay.Name       = Resources.OSMOverlayName;
            openStreetMapOverlay.TileHeight = 512;
            openStreetMapOverlay.TileWidth  = 512;
            openStreetMapOverlay.IsVisible  = false;
            openStreetMapOverlay.TileCache  = new FileBitmapTileCache(cacheFolder, Resources.OSMOverlayName);
            mapControl.Overlays.Add(openStreetMapOverlay);

            BingMapsOverlay bingMapsAerialOverlay = new BingMapsOverlay();

            bingMapsAerialOverlay.Name       = Resources.BingMapsAerialOverlayName;
            bingMapsAerialOverlay.TileHeight = 512;
            bingMapsAerialOverlay.TileWidth  = 512;
            bingMapsAerialOverlay.MapType    = Wpf.BingMapsMapType.Aerial;
            bingMapsAerialOverlay.IsVisible  = false;
            bingMapsAerialOverlay.TileCache  = new FileBitmapTileCache(cacheFolder, Resources.BingMapsAerialOverlayName);
            mapControl.Overlays.Add(bingMapsAerialOverlay);

            BingMapsOverlay bingMapsRoadOverlay = new BingMapsOverlay();

            bingMapsRoadOverlay.Name       = Resources.BingMapsRoadOverlayName;
            bingMapsRoadOverlay.TileHeight = 512;
            bingMapsRoadOverlay.TileWidth  = 512;
            bingMapsRoadOverlay.MapType    = Wpf.BingMapsMapType.Road;
            bingMapsRoadOverlay.IsVisible  = false;
            bingMapsRoadOverlay.TileCache  = new FileBitmapTileCache(cacheFolder, Resources.BingMapsRoadOverlayName);
            mapControl.Overlays.Add(bingMapsRoadOverlay);

            LayerOverlay styleLayersOverLay = new LayerOverlay();

            styleLayersOverLay.TileType = TileType.SingleTile;
            mapControl.Overlays.Add(Resources.StyleLayerOverLayKey, styleLayersOverLay);

            Proj4Projection wgs84ToMercatorProjection = new Proj4Projection();

            wgs84ToMercatorProjection.InternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString();
            wgs84ToMercatorProjection.ExternalProjectionParametersString = Proj4Projection.GetSphericalMercatorParametersString();

            EarthquakeHeatFeatureLayer heatLayer = new EarthquakeHeatFeatureLayer(new ShapeFileFeatureSource(ConfigurationManager.AppSettings["DataShapefileFileName"]));

            heatLayer.HeatStyle = new HeatStyle(10, 100, Resources.MagnitudeColumnName, 0, 12, 100, DistanceUnit.Kilometer);
            heatLayer.FeatureSource.Projection = wgs84ToMercatorProjection;
            heatLayer.Name = Resources.HeatStyleLayerName;
            styleLayersOverLay.Layers.Add(heatLayer);

            ShapeFileFeatureLayer pointLayer = new ShapeFileFeatureLayer(ConfigurationManager.AppSettings["DataShapefileFileName"]);

            pointLayer.FeatureSource.Projection = wgs84ToMercatorProjection;
            pointLayer.Name = Resources.PointStyleLayerName;
            pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.Red, 6, GeoColor.StandardColors.White, 1);
            pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            styleLayersOverLay.Layers.Add(pointLayer);

            EarthquakeIsoLineFeatureLayer isoLineLayer = new EarthquakeIsoLineFeatureLayer(new ShapeFileFeatureSource(ConfigurationManager.AppSettings["DataShapefileFileName"]));

            isoLineLayer.FeatureSource.Projection = wgs84ToMercatorProjection;
            isoLineLayer.Name = Resources.IsolineStyleLayerName;
            styleLayersOverLay.Layers.Add(isoLineLayer);

            //Setup TarckOverlay.
            mapControl.TrackOverlay             = new RadiusMearsureTrackInteractiveOverlay(DistanceUnit.Mile, mapControl.MapUnit);
            mapControl.TrackOverlay.TrackEnded += TrackOverlay_TrackEnded;

            LayerOverlay markerOverlay = new LayerOverlay();

            mapControl.Overlays.Add(Resources.MarkerOverlayKey, markerOverlay);

            PointStyle highLightStyle = new PointStyle();

            highLightStyle.CustomPointStyles.Add(PointStyles.CreateSimpleCircleStyle(GeoColor.FromArgb(50, GeoColor.SimpleColors.Blue), 20, GeoColor.SimpleColors.LightBlue, 1));
            highLightStyle.CustomPointStyles.Add(PointStyles.CreateSimpleCircleStyle(GeoColor.SimpleColors.LightBlue, 9, GeoColor.SimpleColors.Blue, 1));

            markerMemoryLayer = new InMemoryFeatureLayer();
            markerMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = PointStyles.CreateSimpleCircleStyle(GeoColor.SimpleColors.Orange, 8, GeoColor.SimpleColors.White, 1);
            markerMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            markerOverlay.Layers.Add(markerMemoryLayer);

            markerMemoryHighlightLayer = new InMemoryFeatureLayer();
            markerMemoryHighlightLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = highLightStyle;
            markerMemoryHighlightLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            markerOverlay.Layers.Add(markerMemoryHighlightLayer);

            ScaleBarAdornmentLayer scaleBarAdornmentLayer = new ScaleBarAdornmentLayer();

            scaleBarAdornmentLayer.UnitFamily = UnitSystem.Imperial;
            mapControl.AdornmentOverlay.Layers.Add(scaleBarAdornmentLayer);
        }
        private void InitializeOverlays()
        {
            string cacheFolder = Path.Combine(Path.GetTempPath(), "TileCache");

            WorldMapKitWmsDesktopOverlay worldMapKitRoadOverlay = new WorldMapKitWmsDesktopOverlay();

            worldMapKitRoadOverlay.Name       = Resources.WorldMapKitRoadOverlay;
            worldMapKitRoadOverlay.Projection = WorldMapKitProjection.SphericalMercator;
            worldMapKitRoadOverlay.IsVisible  = true;
            worldMapKitRoadOverlay.TileCache  = new FileBitmapTileCache(cacheFolder, Resources.WorldMapKitRoadOverlay);
            worldMapKitRoadOverlay.MapType    = WorldMapKitMapType.Road;
            map.Overlays.Add(Resources.WorldMapKitRoadOverlay, worldMapKitRoadOverlay);

            WorldMapKitWmsDesktopOverlay worldMapKitAerialOverlay = new WorldMapKitWmsDesktopOverlay();

            worldMapKitAerialOverlay.Name       = Resources.WorldMapKitAerialOverlay;
            worldMapKitAerialOverlay.Projection = WorldMapKitProjection.SphericalMercator;
            worldMapKitAerialOverlay.IsVisible  = false;
            worldMapKitAerialOverlay.TileCache  = new FileBitmapTileCache(cacheFolder, Resources.WorldMapKitAerialOverlay);
            worldMapKitAerialOverlay.MapType    = WorldMapKitMapType.Aerial;
            map.Overlays.Add(Resources.WorldMapKitAerialOverlay, worldMapKitAerialOverlay);

            WorldMapKitWmsDesktopOverlay worldMapKitAerialWithLabelsOverlay = new WorldMapKitWmsDesktopOverlay();

            worldMapKitAerialWithLabelsOverlay.Name       = Resources.WorldMapKitAerialWithLabelsOverlay;
            worldMapKitAerialWithLabelsOverlay.Projection = WorldMapKitProjection.SphericalMercator;
            worldMapKitAerialWithLabelsOverlay.IsVisible  = false;
            worldMapKitAerialWithLabelsOverlay.TileCache  = new FileBitmapTileCache(cacheFolder, Resources.WorldMapKitAerialWithLabelsOverlay);
            worldMapKitAerialWithLabelsOverlay.MapType    = WorldMapKitMapType.AerialWithLabels;
            map.Overlays.Add(Resources.WorldMapKitAerialWithLabelsOverlay, worldMapKitAerialWithLabelsOverlay);

            OpenStreetMapOverlay openStreetMapOverlay = new OpenStreetMapOverlay();

            openStreetMapOverlay.Name      = Resources.OSMOverlayName;
            openStreetMapOverlay.IsVisible = false;
            openStreetMapOverlay.TileCache = new FileBitmapTileCache(cacheFolder, Resources.OpenStreetMapKey);
            map.Overlays.Add(Resources.OpenStreetMapKey, openStreetMapOverlay);

            BingMapsOverlay bingMapsAerialOverlay = new BingMapsOverlay();

            bingMapsAerialOverlay.Name      = Resources.BingMapsAerialOverlayName;
            bingMapsAerialOverlay.MapType   = WinForms.BingMapsMapType.Aerial;
            bingMapsAerialOverlay.IsVisible = false;
            bingMapsAerialOverlay.TileCache = new FileBitmapTileCache(cacheFolder, Resources.BingMapsAerial);
            map.Overlays.Add(Resources.BingMapsAerial, bingMapsAerialOverlay);

            BingMapsOverlay bingMapsRoadOverlay = new BingMapsOverlay();

            bingMapsRoadOverlay.Name      = Resources.BingMapsRoadOverlayName;
            bingMapsRoadOverlay.MapType   = WinForms.BingMapsMapType.Road;
            bingMapsRoadOverlay.IsVisible = false;
            bingMapsRoadOverlay.TileCache = new FileBitmapTileCache(cacheFolder, Resources.BingMapsRoad);
            map.Overlays.Add(Resources.BingMapsRoad, bingMapsRoadOverlay);

            LayerOverlay styleLayersOverLay = new LayerOverlay();

            map.Overlays.Add(Resources.StyleLayerOverLayKey, styleLayersOverLay);

            Proj4Projection wgs84ToMercatorProjection = new Proj4Projection();

            wgs84ToMercatorProjection.InternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString();
            wgs84ToMercatorProjection.ExternalProjectionParametersString = Proj4Projection.GetSphericalMercatorParametersString();

            EarthquakeHeatFeatureLayer heatLayer = new EarthquakeHeatFeatureLayer(new ShapeFileFeatureSource(ConfigurationManager.AppSettings["DataShapefileFileName"]));

            heatLayer.IsVisible = false;
            heatLayer.HeatStyle = new HeatStyle(10, 100, Resources.MagnitudeColumnName, 0, 12, 100, DistanceUnit.Kilometer);
            heatLayer.FeatureSource.Projection = wgs84ToMercatorProjection;
            heatLayer.Name = Resources.HeatStyleLayerName;
            styleLayersOverLay.Layers.Add(heatLayer);

            ShapeFileFeatureLayer pointLayer = new ShapeFileFeatureLayer(ConfigurationManager.AppSettings["DataShapefileFileName"]);

            pointLayer.IsVisible = false;
            pointLayer.FeatureSource.Projection = wgs84ToMercatorProjection;
            pointLayer.Name = Resources.PointStyleLayerName;
            pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.Red, 6, GeoColor.StandardColors.White, 1);
            pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            styleLayersOverLay.Layers.Add(pointLayer);

            FeatureSource isoLineFeatureSource         = new ShapeFileFeatureSource(ConfigurationManager.AppSettings["DataShapefileFileName"]);
            EarthquakeIsoLineFeatureLayer isoLineLayer = new EarthquakeIsoLineFeatureLayer(isoLineFeatureSource);

            isoLineLayer.IsVisible = false;
            isoLineLayer.FeatureSource.Projection = wgs84ToMercatorProjection;
            isoLineLayer.Name = Resources.IsolineStyleLayerName;
            styleLayersOverLay.Layers.Add(isoLineLayer);

            LayerOverlay queryResultMarkerOverlay = new LayerOverlay();

            map.Overlays.Add("QueryResultMarkerOverlay", queryResultMarkerOverlay);

            PointStyle highlightStyle = new PointStyle();

            highlightStyle.CustomPointStyles.Add(PointStyles.CreateSimpleCircleStyle(GeoColor.FromArgb(50, GeoColor.SimpleColors.Blue), 20, GeoColor.SimpleColors.LightBlue, 1));
            highlightStyle.CustomPointStyles.Add(PointStyles.CreateSimpleCircleStyle(GeoColor.SimpleColors.LightBlue, 9, GeoColor.SimpleColors.Blue, 1));

            markerMemoryLayer = new InMemoryFeatureLayer();
            markerMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = PointStyles.CreateSimpleCircleStyle(GeoColor.SimpleColors.Orange, 8, GeoColor.SimpleColors.White, 1);
            markerMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            queryResultMarkerOverlay.Layers.Add(markerMemoryLayer);

            markerMemoryHighlightLayer = new InMemoryFeatureLayer();
            markerMemoryHighlightLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = highlightStyle;
            markerMemoryHighlightLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            queryResultMarkerOverlay.Layers.Add(markerMemoryHighlightLayer);
        }
        public static void RefreshCache(this TileOverlay overlay, bool enabled)
        {
            BingMapsOverlay       bingOverlay = overlay as BingMapsOverlay;
            WorldMapKitMapOverlay wmkOverlay  = overlay as WorldMapKitMapOverlay;
            OpenStreetMapOverlay  osmOverlay  = overlay as OpenStreetMapOverlay;

            string cacheId                = string.Empty;
            string cacheFolder            = string.Empty;
            bool   needRefresh            = overlay.TileCache == null;
            FileBitmapTileCache tileCache = null;

            if (bingOverlay != null)
            {
                cacheId               = bingOverlay.MapType.ToString();
                cacheFolder           = Path.Combine(TemporaryPath, "BingMap");
                bingOverlay.TileCache = null;
                needRefresh           = true;

                if (enabled)
                {
                    tileCache = GetTileCache(overlay, cacheFolder, cacheId);
                }
                bingOverlay.TileCache = tileCache;
                overlay.TileCache     = tileCache;
            }
            else if (wmkOverlay != null)
            {
                //cacheId = wmkOverlay.Projection.ToString();
                cacheId = GetDefaultCacheId(wmkOverlay.LayerType, wmkOverlay.Projection, wmkOverlay.MapType);
                string layerType = wmkOverlay.LayerType.ToString();
                if (layerType == Layers.WorldMapKitLayerType.Default.ToString())
                {
                    layerType = Layers.WorldMapKitLayerType.OSMWorldMapKitLayer.ToString();
                }
                cacheFolder = Path.Combine(TemporaryPath, layerType);
                needRefresh = true;

                if (enabled)
                {
                    tileCache = GetTileCache(overlay, cacheFolder, cacheId);
                }
                overlay.TileCache = tileCache;
            }
            else if (osmOverlay != null)
            {
                cacheId              = "SphereMercator";
                cacheFolder          = Path.Combine(TemporaryPath, "OpenStreetMap");
                osmOverlay.TileCache = null;

                if (enabled)
                {
                    tileCache = GetTileCache(overlay, cacheFolder, cacheId);
                }
                osmOverlay.TileCache = tileCache;
                overlay.TileCache    = tileCache;
            }
            else
            {
                cacheId     = Guid.NewGuid().ToString();
                cacheFolder = TemporaryPath;
                if (enabled)
                {
                    tileCache = GetTileCache(overlay, cacheFolder, cacheId);
                }
                overlay.TileCache = tileCache;
                needRefresh       = true;
            }

            if (needRefresh)
            {
                BitmapTileCache tempTileCache = overlay.TileCache as BitmapTileCache;
                if (!overlay.IsBase && tempTileCache != null)
                {
                    Task.Factory.StartNew(cache =>
                    {
                        BitmapTileCache removingCache = (BitmapTileCache)cache;
                        lock (removingCache)
                        {
                            try { removingCache.ClearCache(); }
                            catch { }
                        }
                    }, tempTileCache);
                }
            }
        }
        private void InitializeOverlays()
        {
            string cacheFolder = Path.Combine(Path.GetTempPath(), "TileCache");

            WorldMapKitWmsWpfOverlay worldMapKitRoadOverlay = new WorldMapKitWmsWpfOverlay();
            worldMapKitRoadOverlay.Name = Resources.WorldMapKitOverlayRoadName;
            worldMapKitRoadOverlay.TileHeight = 512;
            worldMapKitRoadOverlay.TileWidth = 512;
            worldMapKitRoadOverlay.Projection = WorldMapKitProjection.SphericalMercator;
            worldMapKitRoadOverlay.MapType = WorldMapKitMapType.Road;
            worldMapKitRoadOverlay.IsVisible = true;
            worldMapKitRoadOverlay.TileCache = new FileBitmapTileCache(cacheFolder, Resources.WorldMapKitOverlayRoadName);
            mapControl.Overlays.Add(worldMapKitRoadOverlay);

            WorldMapKitWmsWpfOverlay worldMapKitAerialOverlay = new WorldMapKitWmsWpfOverlay();
            worldMapKitAerialOverlay.Name = Resources.WorldMapKitOverlayAerialName;
            worldMapKitAerialOverlay.TileHeight = 512;
            worldMapKitAerialOverlay.TileWidth = 512;
            worldMapKitAerialOverlay.Projection = WorldMapKitProjection.SphericalMercator;
            worldMapKitAerialOverlay.MapType = WorldMapKitMapType.Aerial;
            worldMapKitAerialOverlay.IsVisible = false;
            worldMapKitAerialOverlay.TileCache = new FileBitmapTileCache(cacheFolder, Resources.WorldMapKitOverlayAerialName);
            mapControl.Overlays.Add(worldMapKitAerialOverlay);

            WorldMapKitWmsWpfOverlay worldMapKitAerialWithLabelsOverlay = new WorldMapKitWmsWpfOverlay();
            worldMapKitAerialWithLabelsOverlay.Name = Resources.WorldMapKitOverlayAerialWithLabelsName;
            worldMapKitAerialWithLabelsOverlay.TileHeight = 512;
            worldMapKitAerialWithLabelsOverlay.TileWidth = 512;
            worldMapKitAerialWithLabelsOverlay.Projection = WorldMapKitProjection.SphericalMercator;
            worldMapKitAerialWithLabelsOverlay.MapType = WorldMapKitMapType.AerialWithLabels;
            worldMapKitAerialWithLabelsOverlay.IsVisible = false;
            worldMapKitAerialWithLabelsOverlay.TileCache = new FileBitmapTileCache(cacheFolder, Resources.WorldMapKitOverlayAerialWithLabelsName);
            mapControl.Overlays.Add(worldMapKitAerialWithLabelsOverlay);

            OpenStreetMapOverlay openStreetMapOverlay = new OpenStreetMapOverlay();
            openStreetMapOverlay.Name = Resources.OSMOverlayName;
            openStreetMapOverlay.TileHeight = 512;
            openStreetMapOverlay.TileWidth = 512;
            openStreetMapOverlay.IsVisible = false;
            openStreetMapOverlay.TileCache = new FileBitmapTileCache(cacheFolder, Resources.OSMOverlayName);
            mapControl.Overlays.Add(openStreetMapOverlay);

            BingMapsOverlay bingMapsAerialOverlay = new BingMapsOverlay();
            bingMapsAerialOverlay.Name = Resources.BingMapsAerialOverlayName;
            bingMapsAerialOverlay.TileHeight = 512;
            bingMapsAerialOverlay.TileWidth = 512;
            bingMapsAerialOverlay.MapType = BingMapsMapType.Aerial;
            bingMapsAerialOverlay.IsVisible = false;
            bingMapsAerialOverlay.TileCache = new FileBitmapTileCache(cacheFolder, Resources.BingMapsAerialOverlayName);
            mapControl.Overlays.Add(bingMapsAerialOverlay);

            BingMapsOverlay bingMapsRoadOverlay = new BingMapsOverlay();
            bingMapsRoadOverlay.Name = Resources.BingMapsRoadOverlayName;
            bingMapsRoadOverlay.TileHeight = 512;
            bingMapsRoadOverlay.TileWidth = 512;
            bingMapsRoadOverlay.MapType = BingMapsMapType.Road;
            bingMapsRoadOverlay.IsVisible = false;
            bingMapsRoadOverlay.TileCache = new FileBitmapTileCache(cacheFolder, Resources.BingMapsRoadOverlayName);
            mapControl.Overlays.Add(bingMapsRoadOverlay);

            LayerOverlay styleLayersOverLay = new LayerOverlay();
            styleLayersOverLay.TileType = TileType.SingleTile;
            mapControl.Overlays.Add(Resources.StyleLayerOverLayKey, styleLayersOverLay);

            ManagedProj4Projection wgs84ToMercatorProjection = new ManagedProj4Projection();
            wgs84ToMercatorProjection.InternalProjectionParametersString = ManagedProj4Projection.GetDecimalDegreesParametersString();
            wgs84ToMercatorProjection.ExternalProjectionParametersString = ManagedProj4Projection.GetSphericalMercatorParametersString();

            EarthquakeHeatFeatureLayer heatLayer = new EarthquakeHeatFeatureLayer(new ShapeFileFeatureSource(ConfigurationManager.AppSettings["DataShapefileFileName"]));
            heatLayer.HeatStyle = new HeatStyle(10, 100, Resources.MagnitudeColumnName, 0, 12, 100, DistanceUnit.Kilometer);
            heatLayer.FeatureSource.Projection = wgs84ToMercatorProjection;
            heatLayer.Name = Resources.HeatStyleLayerName;
            styleLayersOverLay.Layers.Add(heatLayer);

            ShapeFileFeatureLayer pointLayer = new ShapeFileFeatureLayer(ConfigurationManager.AppSettings["DataShapefileFileName"]);
            pointLayer.FeatureSource.Projection = wgs84ToMercatorProjection;
            pointLayer.Name = Resources.PointStyleLayerName;
            pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.Red, 6, GeoColor.StandardColors.White, 1);
            pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            styleLayersOverLay.Layers.Add(pointLayer);

            EarthquakeIsoLineFeatureLayer isoLineLayer = new EarthquakeIsoLineFeatureLayer(new ShapeFileFeatureSource(ConfigurationManager.AppSettings["DataShapefileFileName"]));
            isoLineLayer.FeatureSource.Projection = wgs84ToMercatorProjection;
            isoLineLayer.Name = Resources.IsolineStyleLayerName;
            styleLayersOverLay.Layers.Add(isoLineLayer);

            //Setup TarckOverlay.
            mapControl.TrackOverlay = new RadiusMearsureTrackInteractiveOverlay(DistanceUnit.Mile, mapControl.MapUnit);
            mapControl.TrackOverlay.TrackEnded += TrackOverlay_TrackEnded;

            LayerOverlay markerOverlay = new LayerOverlay();
            mapControl.Overlays.Add(Resources.MarkerOverlayKey, markerOverlay);

            PointStyle highLightStyle = new PointStyle();
            highLightStyle.CustomPointStyles.Add(PointStyles.CreateSimpleCircleStyle(GeoColor.FromArgb(50, GeoColor.SimpleColors.Blue), 20, GeoColor.SimpleColors.LightBlue, 1));
            highLightStyle.CustomPointStyles.Add(PointStyles.CreateSimpleCircleStyle(GeoColor.SimpleColors.LightBlue, 9, GeoColor.SimpleColors.Blue, 1));

            markerMemoryLayer = new InMemoryFeatureLayer();
            markerMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.SimpleColors.Orange, 8, GeoColor.SimpleColors.White, 1);
            markerMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            markerOverlay.Layers.Add(markerMemoryLayer);

            markerMemoryHighlightLayer = new InMemoryFeatureLayer();
            markerMemoryHighlightLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = highLightStyle;
            markerMemoryHighlightLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            markerOverlay.Layers.Add(markerMemoryHighlightLayer);

            ScaleBarAdornmentLayer scaleBarAdornmentLayer = new ScaleBarAdornmentLayer();
            scaleBarAdornmentLayer.UnitFamily = UnitSystem.Imperial;
            mapControl.AdornmentOverlay.Layers.Add(scaleBarAdornmentLayer);
        }
Example #16
0
        private void AddOverlays(Map map)
        {
            // Background Overlay
            WorldStreetsAndImageryOverlay worldMapKitRoadOverlay = new WorldStreetsAndImageryOverlay("World Map Kit Road");

            worldMapKitRoadOverlay.Projection = WorldStreetsAndImageryProjection.SphericalMercator;
            worldMapKitRoadOverlay.MapType    = WorldStreetsAndImageryMapType.Road;
            map.CustomOverlays.Add(worldMapKitRoadOverlay);

            WorldStreetsAndImageryOverlay worldMapKitAerialOverlay = new WorldStreetsAndImageryOverlay("World Map Kit Aerial");

            worldMapKitAerialOverlay.Projection = WorldStreetsAndImageryProjection.SphericalMercator;
            worldMapKitAerialOverlay.MapType    = WorldStreetsAndImageryMapType.Aerial;
            map.CustomOverlays.Add(worldMapKitAerialOverlay);

            WorldStreetsAndImageryOverlay worldMapKitAerialWithLabelsOverlay = new WorldStreetsAndImageryOverlay("World Map Kit Aerial With Labels");

            worldMapKitAerialWithLabelsOverlay.Projection = WorldStreetsAndImageryProjection.SphericalMercator;
            worldMapKitAerialWithLabelsOverlay.MapType    = WorldStreetsAndImageryMapType.AerialWithLabels;
            map.CustomOverlays.Add(worldMapKitAerialWithLabelsOverlay);

            OpenStreetMapOverlay openStreetMapOverlay = new OpenStreetMapOverlay("Open Street Map");

            map.CustomOverlays.Add(openStreetMapOverlay);

            LayerOverlay poisOverlay = new LayerOverlay("PoisOverlay");

            poisOverlay.IsBaseOverlay = false;
            poisOverlay.IsVisibleInOverlaySwitcher = false;
            map.CustomOverlays.Add(poisOverlay);

            // POI Overlay
            Proj4Projection proj4 = new Proj4Projection();

            proj4.InternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString();
            proj4.ExternalProjectionParametersString = Proj4Projection.GetSphericalMercatorParametersString();
            proj4.Open();

            ShapeFileFeatureLayer hotelsLayer = new ShapeFileFeatureLayer(Server.MapPath(ConfigurationManager.AppSettings["HotelsShapeFilePathName"]), GeoFileReadWriteMode.Read);

            hotelsLayer.Name         = Resource.Hotels;
            hotelsLayer.Transparency = 120f;
            hotelsLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle   = new PointStyle(new GeoImage(Server.MapPath("~/Content/Images/Hotel.png")));
            hotelsLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            hotelsLayer.FeatureSource.Projection = proj4;
            poisOverlay.Layers.Add(hotelsLayer.Name, hotelsLayer);

            ShapeFileFeatureLayer medicalFacilitesLayer = new ShapeFileFeatureLayer(Server.MapPath(ConfigurationManager.AppSettings["MedicalFacilitiesShapeFilePathName"]), GeoFileReadWriteMode.Read);

            medicalFacilitesLayer.Name         = Resource.MedicalFacilites;
            medicalFacilitesLayer.Transparency = 120f;
            medicalFacilitesLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle   = new PointStyle(new GeoImage(Server.MapPath("~/Content/Images/DrugStore.png")));
            medicalFacilitesLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            medicalFacilitesLayer.FeatureSource.Projection = proj4;
            poisOverlay.Layers.Add(medicalFacilitesLayer.Name, medicalFacilitesLayer);

            ShapeFileFeatureLayer publicFacilitesLayer = new ShapeFileFeatureLayer(Server.MapPath(ConfigurationManager.AppSettings["PublicFacilitiesShapeFilePathName"]), GeoFileReadWriteMode.Read);

            publicFacilitesLayer.Name         = Resource.PublicFacilites;
            publicFacilitesLayer.Transparency = 120f;
            publicFacilitesLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle   = new PointStyle(new GeoImage(Server.MapPath("~/Content/Images/public_facility.png")));
            publicFacilitesLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            publicFacilitesLayer.FeatureSource.Projection = proj4;
            poisOverlay.Layers.Add(publicFacilitesLayer.Name, publicFacilitesLayer);

            ShapeFileFeatureLayer restaurantsLayer = new ShapeFileFeatureLayer(Server.MapPath(ConfigurationManager.AppSettings["RestaurantsShapeFilePathName"]), GeoFileReadWriteMode.Read);

            restaurantsLayer.Name         = Resource.Restaurants;
            restaurantsLayer.Transparency = 120f;
            restaurantsLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle   = new PointStyle(new GeoImage(Server.MapPath("~/Content/Images/restaurant.png")));
            restaurantsLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            restaurantsLayer.FeatureSource.Projection = proj4;
            poisOverlay.Layers.Add(restaurantsLayer.Name, restaurantsLayer);

            ShapeFileFeatureLayer schoolsLayer = new ShapeFileFeatureLayer(Server.MapPath(ConfigurationManager.AppSettings["SchoolsShapeFilePathName"]), GeoFileReadWriteMode.Read);

            schoolsLayer.Name         = Resource.Schools;
            schoolsLayer.Transparency = 120f;
            schoolsLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle   = new PointStyle(new GeoImage(Server.MapPath("~/Content/Images/school.png")));
            schoolsLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            schoolsLayer.FeatureSource.Projection = proj4;
            poisOverlay.Layers.Add(schoolsLayer.Name, schoolsLayer);

            // Restrict area Overlay
            ShapeFileFeatureLayer restrictedLayer = new ShapeFileFeatureLayer(Server.MapPath(ConfigurationManager.AppSettings["RestrictedShapeFilePathName"]), GeoFileReadWriteMode.Read);
            AreaStyle             extentStyle     = new AreaStyle();

            extentStyle.CustomAreaStyles.Add(new AreaStyle(new GeoSolidBrush(GeoColor.SimpleColors.Transparent))
            {
                OutlinePen = new GeoPen(GeoColor.SimpleColors.White, 5.5f)
            });
            extentStyle.CustomAreaStyles.Add(new AreaStyle(new GeoSolidBrush(GeoColor.SimpleColors.Transparent))
            {
                OutlinePen = new GeoPen(GeoColor.SimpleColors.Red, 1.5f)
                {
                    DashStyle = LineDashStyle.Dash
                }
            });
            restrictedLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = extentStyle;
            restrictedLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            restrictedLayer.FeatureSource.Projection = proj4;

            LayerOverlay restrictOverlay = new LayerOverlay("RestrictOverlay");

            restrictOverlay.IsBaseOverlay = false;
            restrictOverlay.IsVisibleInOverlaySwitcher = false;
            restrictOverlay.Layers.Add("RestrictLayer", restrictedLayer);
            map.CustomOverlays.Add(restrictOverlay);

            // Queried Service Overlay
            InMemoryFeatureLayer serviceAreaLayer    = new InMemoryFeatureLayer();
            GeoColor             serviceAreaGeoColor = new GeoColor(120, GeoColor.FromHtml("#1749c9"));

            serviceAreaLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyles.CreateSimpleAreaStyle(serviceAreaGeoColor, GeoColor.FromHtml("#fefec1"), 2, LineDashStyle.Solid);
            serviceAreaLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            InMemoryFeatureLayer highlightFeatureLayer = new InMemoryFeatureLayer();

            highlightFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay queriedOverlay = new LayerOverlay("QueriedOverlay");

            queriedOverlay.IsBaseOverlay = false;
            queriedOverlay.IsVisibleInOverlaySwitcher = false;
            queriedOverlay.TileType = TileType.SingleTile;
            queriedOverlay.Layers.Add("highlightFeatureLayer", highlightFeatureLayer);
            queriedOverlay.Layers.Add("serviceArea", serviceAreaLayer);
            map.CustomOverlays.Add(queriedOverlay);

            // Marker Overlay
            map.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage = new WebImage("/Content/Images/selectedHalo.png")
            {
                ImageOffsetX = -16, ImageOffsetY = -16
            };
            map.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.BorderWidth = 1;
            map.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.BorderColor = GeoColor.StandardColors.Gray;
            map.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.AutoSize    = true;
            map.MarkerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            map.MarkerOverlay.IsVisibleInOverlaySwitcher = false;

            // Drawn Point
            InMemoryMarkerOverlay markerOverlay = new InMemoryMarkerOverlay("DrawnPointOverlay");

            markerOverlay.FeatureSource.InternalFeatures.Add(new Feature(new PointShape(-10776838.0796536, 3912346.50475619)));     // Add a initial point for query
            markerOverlay.IsVisibleInOverlaySwitcher = false;
            markerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage = new WebImage("/Content/Images/drawPoint.png")
            {
                ImageOffsetX = -16, ImageOffsetY = -32
            };
            markerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            map.CustomOverlays.Add(markerOverlay);

            // Legend Layer
            LegendAdornmentLayer legendlayer = new LegendAdornmentLayer {
                Height = 135, Location = AdornmentLocation.LowerRight
            };

            map.AdornmentOverlay.Layers.Add(legendlayer);

            LegendItem hotelsLayeritem = new LegendItem();

            hotelsLayeritem.ImageStyle = hotelsLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle;
            hotelsLayeritem.TextStyle  = WorldStreetsTextStyles.GeneralPurpose(Resource.Hotels, 10);
            legendlayer.LegendItems.Add("hotels", hotelsLayeritem);

            LegendItem medicalFacilitesLayeritem = new LegendItem();

            medicalFacilitesLayeritem.ImageStyle = medicalFacilitesLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle;
            hotelsLayeritem.TextStyle            = WorldStreetsTextStyles.GeneralPurpose(Resource.MedicalFacilites, 10);

            legendlayer.LegendItems.Add("medicalFacilites", medicalFacilitesLayeritem);

            LegendItem publicFacilitesLayeritem = new LegendItem();

            publicFacilitesLayeritem.ImageStyle = publicFacilitesLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle;
            hotelsLayeritem.TextStyle           = WorldStreetsTextStyles.GeneralPurpose(Resource.PublicFacilites, 10);

            legendlayer.LegendItems.Add("publicFacilites", publicFacilitesLayeritem);

            LegendItem restaurantsLayeritem = new LegendItem();

            restaurantsLayeritem.ImageStyle = restaurantsLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle;
            hotelsLayeritem.TextStyle       = WorldStreetsTextStyles.GeneralPurpose(Resource.Restaurants, 10);

            legendlayer.LegendItems.Add("restaurants", restaurantsLayeritem);

            LegendItem schoolsLayeritem = new LegendItem();

            schoolsLayeritem.ImageStyle = schoolsLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle;
            hotelsLayeritem.TextStyle   = WorldStreetsTextStyles.GeneralPurpose(Resource.Schools, 10);

            legendlayer.LegendItems.Add("schools", schoolsLayeritem);

            // Scale bar layer
            ScaleBarAdornmentLayer scaleBarAdormentLayer = new ScaleBarAdornmentLayer();

            scaleBarAdormentLayer.Location       = AdornmentLocation.LowerLeft;
            scaleBarAdormentLayer.XOffsetInPixel = 10;
            map.AdornmentOverlay.Layers.Add("ScaleBar", scaleBarAdormentLayer);
            map.AdornmentOverlay.IsVisibleInOverlaySwitcher = false;

            // Create the Routine Engine.
            string streetShapeFilePathName = Server.MapPath(ConfigurationManager.AppSettings["StreetShapeFilePathName"]);
            string streetRtgFilePathName   = Path.ChangeExtension(streetShapeFilePathName, ".rtg");

            RtgRoutingSource routingSource = new RtgRoutingSource(streetRtgFilePathName);
            FeatureSource    featureSource = new ShapeFileFeatureSource(streetShapeFilePathName);

            featureSource.Projection    = proj4;
            routingEngine               = new RoutingEngine(routingSource, featureSource);
            routingEngine.GeographyUnit = GeographyUnit.Meter;
        }
        public static OpenStreetMapOverlay CreateOpenStreetMapOverlay()
        {
            string cacheDirectory = Path.Combine(Path.GetTempPath(), "TileCache");
            const string openStreetMapOverlayName = "Open Street Map";

            OpenStreetMapOverlay openStreetMapOverlay = new OpenStreetMapOverlay();

            //  Set the name of overlay and it will be displayed in the swicher overlay.
            openStreetMapOverlay.Name = openStreetMapOverlayName;

            //  Set the image format as Jpeg. The default value is Png.
            openStreetMapOverlay.ImageFormat = TileImageFormat.Jpeg;

            //  Set the height and width of the image. The default value is 256.
            openStreetMapOverlay.TileHeight = 512;
            openStreetMapOverlay.TileWidth = 512;
            //  Set cache of the tiles, it indicates where the tiles will be saved to.
            //  As it can improve the performance of application.
            openStreetMapOverlay.TileCache = new FileBitmapTileCache(cacheDirectory, openStreetMapOverlayName);

            return openStreetMapOverlay;
        }
        private void InitializeOverlays()
        {
            string cacheFolder = Path.Combine(Path.GetTempPath(), "TileCache");

            WorldMapKitWmsWpfOverlay worldMapKitRoadOverlay = new WorldMapKitWmsWpfOverlay();

            worldMapKitRoadOverlay.Name       = Resources.WorldMapKitOverlayRoadName;
            worldMapKitRoadOverlay.TileHeight = 512;
            worldMapKitRoadOverlay.TileWidth  = 512;
            worldMapKitRoadOverlay.Projection = WorldMapKitProjection.SphericalMercator;
            worldMapKitRoadOverlay.MapType    = WorldMapKitMapType.Road;
            worldMapKitRoadOverlay.IsVisible  = true;
            worldMapKitRoadOverlay.TileCache  = new FileBitmapTileCache(cacheFolder, Resources.WorldMapKitOverlayRoadName);
            mapControl.Overlays.Add(worldMapKitRoadOverlay);

            WorldMapKitWmsWpfOverlay worldMapKitAerialOverlay = new WorldMapKitWmsWpfOverlay();

            worldMapKitAerialOverlay.Name       = Resources.WorldMapKitOverlayAerialName;
            worldMapKitAerialOverlay.TileHeight = 512;
            worldMapKitAerialOverlay.TileWidth  = 512;
            worldMapKitAerialOverlay.Projection = WorldMapKitProjection.SphericalMercator;
            worldMapKitAerialOverlay.MapType    = WorldMapKitMapType.Aerial;
            worldMapKitAerialOverlay.IsVisible  = false;
            worldMapKitAerialOverlay.TileCache  = new FileBitmapTileCache(cacheFolder, Resources.WorldMapKitOverlayAerialName);
            mapControl.Overlays.Add(worldMapKitAerialOverlay);

            WorldMapKitWmsWpfOverlay worldMapKitAerialWithLabelsOverlay = new WorldMapKitWmsWpfOverlay();

            worldMapKitAerialWithLabelsOverlay.Name       = Resources.WorldMapKitOverlayAerialWithLabelsName;
            worldMapKitAerialWithLabelsOverlay.TileHeight = 512;
            worldMapKitAerialWithLabelsOverlay.TileWidth  = 512;
            worldMapKitAerialWithLabelsOverlay.Projection = WorldMapKitProjection.SphericalMercator;
            worldMapKitAerialWithLabelsOverlay.MapType    = WorldMapKitMapType.AerialWithLabels;
            worldMapKitAerialWithLabelsOverlay.IsVisible  = false;
            worldMapKitAerialWithLabelsOverlay.TileCache  = new FileBitmapTileCache(cacheFolder, Resources.WorldMapKitOverlayAerialWithLabelsName);
            mapControl.Overlays.Add(worldMapKitAerialWithLabelsOverlay);

            OpenStreetMapOverlay openStreetMapOverlay = new OpenStreetMapOverlay();

            openStreetMapOverlay.Name       = Resources.OpenStreetMapName;
            openStreetMapOverlay.TileHeight = 512;
            openStreetMapOverlay.TileWidth  = 512;
            openStreetMapOverlay.IsVisible  = false;
            openStreetMapOverlay.TileCache  = new FileBitmapTileCache(cacheFolder, "OpenStreetMap");
            mapControl.Overlays.Add(Resources.OpenStreetMapKey, openStreetMapOverlay);

            BingMapsOverlay bingMapsAerialOverlay = new BingMapsOverlay();

            bingMapsAerialOverlay.Name       = Resources.BingMapsAerialMapName;
            bingMapsAerialOverlay.TileHeight = 512;
            bingMapsAerialOverlay.TileWidth  = 512;
            bingMapsAerialOverlay.MapType    = Wpf.BingMapsMapType.Aerial;
            bingMapsAerialOverlay.IsVisible  = false;
            bingMapsAerialOverlay.TileCache  = new FileBitmapTileCache(cacheFolder, "BingMapsAerial");
            mapControl.Overlays.Add(Resources.BingAerialKey, bingMapsAerialOverlay);

            BingMapsOverlay bingMapsRoadOverlay = new BingMapsOverlay();

            bingMapsRoadOverlay.Name       = Resources.BingMapsRoadMapName;
            bingMapsRoadOverlay.TileHeight = 512;
            bingMapsRoadOverlay.TileWidth  = 512;
            bingMapsRoadOverlay.MapType    = Wpf.BingMapsMapType.Road;
            bingMapsRoadOverlay.IsVisible  = false;
            bingMapsRoadOverlay.TileCache  = new FileBitmapTileCache(cacheFolder, "BingMapsRoad");
            mapControl.Overlays.Add(Resources.BingRoadKey, bingMapsRoadOverlay);

            InMemoryFeatureLayer spatialFenceLayer = new InMemoryFeatureLayer();

            spatialFenceLayer.Open();
            spatialFenceLayer.Columns.Add(new FeatureSourceColumn(Resources.RestrictedName, "Charater", 10));
            spatialFenceLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = new AreaStyle(new GeoPen(GeoColor.FromArgb(255, 204, 204, 204), 2), new GeoSolidBrush(GeoColor.FromArgb(112, 255, 0, 0)));
            spatialFenceLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle    = TextStyles.CreateSimpleTextStyle(Resources.RestrictedName, "Arial", 12, DrawingFontStyles.Regular, GeoColor.StandardColors.Black, GeoColor.SimpleColors.White, 2);
            spatialFenceLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay spatialFenceOverlay = new LayerOverlay();

            spatialFenceOverlay.TileType = TileType.SingleTile;
            spatialFenceOverlay.Name     = Resources.SpatialFenceOverlayName;
            spatialFenceOverlay.Layers.Add(Resources.SpatialFenceLayerName, spatialFenceLayer);
            mapControl.Overlays.Add(Resources.SpatialFenceOverlayName, spatialFenceOverlay);

            LayerOverlay traceOverlay = new LayerOverlay();

            traceOverlay.Name     = Resources.TraceOverlayName;
            traceOverlay.TileType = TileType.SingleTile;
            mapControl.Overlays.Add(Resources.TraceOverlayName, traceOverlay);

            mapControl.Overlays.Add(Resources.PopupOverlayName, new PopupOverlay {
                Name = Resources.PopupOverlayName
            });

            ScaleBarAdornmentLayer scaleBarAdormentLayer = new ScaleBarAdornmentLayer();

            scaleBarAdormentLayer.UnitFamily = UnitSystem.Metric;
            mapControl.AdornmentOverlay.Layers.Add(Resources.ScaleBarName, scaleBarAdormentLayer);
        }
Example #19
0
        private void InitializeMap()
        {
            string targetDictionary = @"AppData/SampleData";

            Proj4Projection proj4    = Global.GetWgs84ToMercatorProjection();
            string          rootPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/CacheImages";

            // WMK
            WorldMapKitOverlay wmkOverlay = new WorldMapKitOverlay();

            wmkOverlay.Projection = ThinkGeo.MapSuite.iOS.WorldMapKitProjection.SphericalMercator;

            // OSM
            OpenStreetMapOverlay osmOverlay = new OpenStreetMapOverlay();

            osmOverlay.TileCache = new FileBitmapTileCache(rootPath + "/OpenStreetMaps", "SphericalMercator");
            osmOverlay.TileCache.TileMatrix.BoundingBoxUnit = GeographyUnit.Meter;
            osmOverlay.TileCache.TileMatrix.BoundingBox     = osmOverlay.GetBoundingBox();
            osmOverlay.TileCache.ImageFormat = TileImageFormat.Jpeg;
            osmOverlay.IsVisible             = false;

            // Bing - Aerial
            BingMapsOverlay bingMapsAerialOverlay = new BingMapsOverlay();

            bingMapsAerialOverlay.MapStyle  = ThinkGeo.MapSuite.iOS.BingMapsMapType.AerialWithLabels;
            bingMapsAerialOverlay.TileCache = new FileBitmapTileCache(rootPath + "/BingMaps", "AerialWithLabels");
            bingMapsAerialOverlay.TileCache.TileMatrix.BoundingBoxUnit = GeographyUnit.Meter;
            bingMapsAerialOverlay.TileCache.TileMatrix.BoundingBox     = bingMapsAerialOverlay.GetBoundingBox();
            bingMapsAerialOverlay.TileCache.ImageFormat = TileImageFormat.Jpeg;
            bingMapsAerialOverlay.IsVisible             = false;

            // Bing - Road
            BingMapsOverlay bingMapsRoadOverlay = new BingMapsOverlay();

            bingMapsRoadOverlay.MapStyle  = ThinkGeo.MapSuite.iOS.BingMapsMapType.Road;
            bingMapsRoadOverlay.TileCache = new FileBitmapTileCache(rootPath + "/BingMaps", "Road");
            bingMapsRoadOverlay.TileCache.TileMatrix.BoundingBoxUnit = GeographyUnit.Meter;
            bingMapsRoadOverlay.TileCache.TileMatrix.BoundingBox     = bingMapsRoadOverlay.GetBoundingBox();
            bingMapsRoadOverlay.TileCache.ImageFormat = TileImageFormat.Jpeg;
            bingMapsRoadOverlay.IsVisible             = false;

            // Earthquake points
            ShapeFileFeatureLayer earthquakePointLayer = new ShapeFileFeatureLayer(Path.Combine(targetDictionary, "usEarthquake.shp"));

            earthquakePointLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(PointStyles.CreateSimpleCircleStyle(GeoColor.SimpleColors.Red, 5, GeoColor.SimpleColors.White, 1));
            earthquakePointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            earthquakePointLayer.FeatureSource.Projection = proj4;

            ShapeFileFeatureSource earthquakeHeatFeatureSource = new ShapeFileFeatureSource(Path.Combine(targetDictionary, "usEarthquake_Simplified.shp"));

            earthquakeHeatFeatureSource.Projection = proj4;

            HeatLayer earthquakeHeatLayer = new HeatLayer(earthquakeHeatFeatureSource);

            earthquakeHeatLayer.HeatStyle       = new HeatStyle(10, 75, DistanceUnit.Kilometer);
            earthquakeHeatLayer.HeatStyle.Alpha = 180;
            earthquakeHeatLayer.IsVisible       = false;

            LayerOverlay highlightOverlay = new LayerOverlay();

            highlightOverlay.Layers.Add("EarthquakePointLayer", earthquakePointLayer);
            highlightOverlay.Layers.Add("EarthquakeHeatLayer", earthquakeHeatLayer);

            // Highlighted points
            InMemoryFeatureLayer selectedMarkerLayer = new InMemoryFeatureLayer();

            selectedMarkerLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = PointStyles.CreateSimpleCircleStyle(GeoColor.SimpleColors.Orange, 8, GeoColor.SimpleColors.White, 2);
            selectedMarkerLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            PointStyle highLightMarkerStyle = new PointStyle();

            highLightMarkerStyle.CustomPointStyles.Add(PointStyles.CreateSimpleCircleStyle(GeoColor.FromArgb(50, GeoColor.SimpleColors.Blue), 20, GeoColor.SimpleColors.LightBlue, 1));
            highLightMarkerStyle.CustomPointStyles.Add(PointStyles.CreateSimpleCircleStyle(GeoColor.FromArgb(255, 0, 122, 255), 10, GeoColor.SimpleColors.White, 2));

            InMemoryFeatureLayer highlightMarkerLayer = new InMemoryFeatureLayer();

            highlightMarkerLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = highLightMarkerStyle;
            highlightMarkerLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            highlightOverlay.Layers.Add("SelectMarkerLayer", selectedMarkerLayer);
            highlightOverlay.Layers.Add("HighlightMarkerLayer", highlightMarkerLayer);

            // Maps
            iOSMap                 = new MapView(View.Frame);
            iOSMap.MapUnit         = GeographyUnit.Meter;
            iOSMap.ZoomLevelSet    = new SphericalMercatorZoomLevelSet();
            iOSMap.CurrentExtent   = new RectangleShape(-19062735.6816748, 9273256.52450252, -5746827.16371793, 2673516.56066139);
            iOSMap.BackgroundColor = new UIColor(233, 229, 220, 200);

            iOSMap.Overlays.Add(Global.OpenStreetMapOverlayKey, osmOverlay);
            iOSMap.Overlays.Add(Global.WorldMapKitOverlayKey, wmkOverlay);
            iOSMap.Overlays.Add(Global.BingMapsAerialOverlayKey, bingMapsAerialOverlay);
            iOSMap.Overlays.Add(Global.BingMapsRoadOverlayKey, bingMapsRoadOverlay);
            iOSMap.Overlays.Add(Global.HighLightOverlayKey, highlightOverlay);

            iOSMap.TrackOverlay.TrackShapeLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Clear();
            iOSMap.TrackOverlay.TrackShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.FromArgb(80, GeoColor.SimpleColors.LightGreen), 8);
            iOSMap.TrackOverlay.TrackShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle  = LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.White, 3, true);
            iOSMap.TrackOverlay.TrackShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle  = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(80, GeoColor.SimpleColors.LightGreen), GeoColor.SimpleColors.White, 2);
            iOSMap.TrackOverlay.TrackEnded += TrackInteractiveOverlayOnTrackEnded;
            Global.MapView = iOSMap;

            View.Add(iOSMap);
            iOSMap.Refresh();
        }