void SerializationManager_Deserializing(object sender, SerializingEventArgs e) { //try reset projection! if (App.Map.MapFrame.Projection != DotSpatial.Projections.KnownCoordinateSystems.Projected.World.WebMercator) { //App.Map.MapFrame.Reproject(DotSpatial.Projections.KnownCoordinateSystems.Projected.World.WebMercator); MapFrameProjectionHelper.ReprojectMapFrame(App.Map.MapFrame, DotSpatial.Projections.KnownCoordinateSystems.Projected.World.WebMercator.ToEsriString()); } myProjectManager.OpeningProject(); Shell.Text = string.Format("{0} - {1}", HYDRODESKTOP_NAME, GetProjectShortName()); //setup new db information SeriesControl.SetupDatabase(); if (App.Map.Projection != null) { latLongDisplay.MapProjectionString = App.Map.Projection.ToEsriString(); } }
private void ForceMaxExtentZoom() { ProjectionInfo webMerc = KnownCoordinateSystems.Projected.World.WebMercator; //special case when there are no other layers in the map. Set map projection to WebMercator and zoom to max ext. MapFrameProjectionHelper.ReprojectMapFrame(App.Map.MapFrame, webMerc.ToEsriString()); // modifying the view extents didn't get the job done, so we are creating a new featureset. // App.Map.ViewExtents = new Extent(TileCalculator.MinWebMercX, TileCalculator.MinWebMercY, TileCalculator.MaxWebMercX, TileCalculator.MaxWebMercY); var fs = new FeatureSet(FeatureType.Point); fs.Features.Add(new Coordinate(TileCalculator.MinWebMercX, TileCalculator.MinWebMercY)); fs.Features.Add(new Coordinate(TileCalculator.MaxWebMercX, TileCalculator.MaxWebMercY)); fs.Projection = App.Map.Projection; _featureSetLayer = App.Map.Layers.Add(fs); // hide the points that we are adding. _featureSetLayer.LegendItemVisible = false; App.Map.ZoomToMaxExtent(); }
private void EnableBasemapFetching(string tileServerName, string tileServerUrl) { ProjectionInfo webMerc = KnownCoordinateSystems.Projected.World.WebMercator; // Zoom out as much as possible if there are no other layers. //reproject any existing layer in non-webMercator projection. //if (App.Map.Layers.Count == 0 || App.Map.Projection != webMerc) if (App.Map.Layers.Count == 0) { ForceMaxExtentZoom(); } else if (!App.Map.Projection.Equals(webMerc)) { //get original view extents App.ProgressHandler.Progress(String.Empty, 0, "Reprojecting Map Layers..."); double[] viewExtentXY = new[] { App.Map.ViewExtents.MinX, App.Map.ViewExtents.MinY, App.Map.ViewExtents.MaxX, App.Map.ViewExtents.MaxY }; double[] viewExtentZ = new[] { 0.0, 0.0 }; //reproject view extents Reproject.ReprojectPoints(viewExtentXY, viewExtentZ, App.Map.Projection, webMerc, 0, 2); //set the new map extents App.Map.ViewExtents = new Extent(viewExtentXY); //if projection is not WebMercator - reproject all layers: MapFrameProjectionHelper.ReprojectMapFrame(App.Map.MapFrame, webMerc.ToEsriString()); App.ProgressHandler.Progress(String.Empty, 0, "Loading Basemap..."); } // Special case for WMS if (tileServerName.Equals(Properties.Resources.WMSMap, StringComparison.InvariantCultureIgnoreCase)) { using (var wmsDialog = new WMSServerParameters()) { if (wmsDialog.ShowDialog() != DialogResult.OK) { return; } _tileManager.WmsServerInfo = wmsDialog.WmsServerInfo; } } // Other is a custom service if (tileServerName.Equals(Other, StringComparison.InvariantCultureIgnoreCase)) { tileServerUrl = Interaction.InputBox("Please provide the Url for the service.", DefaultResponse: "http://tiles.virtualearth.net/tiles/h{key}.jpeg?g=461&mkt=en-us&n=z"); // Let the user cancel... if (String.IsNullOrWhiteSpace(tileServerUrl)) { return; } } EnableBasemapLayer(); _tileManager.ChangeService(tileServerName, tileServerUrl); if (_bw.IsBusy != true) { _bw.RunWorkerAsync(); } }