public WmsServiceProvider(string name) : base(name, null, new MemoryCache<byte[]>()) { Configure = delegate { using (var wmsDialog = new WMSServerParameters(_data)) { if (wmsDialog.ShowDialog() != DialogResult.OK) return false; _data = wmsDialog.WmsInfo; if (_data != null) { TileSource = WmsTileSource.Create(_data); TileCache = new MemoryCache<byte[]>(); return true; } return false; } }; }
public WmsServiceProvider(string name) : base(name, null, new MemoryCache <byte[]>()) { Configure = delegate { using (var wmsDialog = new WMSServerParameters(_data)) { if (wmsDialog.ShowDialog() != DialogResult.OK) { return(false); } _data = wmsDialog.WmsInfo; if (_data != null) { TileSource = WmsTileSource.Create(_data); TileCache = new MemoryCache <byte[]>(); return(true); } return(false); } }; }
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 WmsServerInfo wmsServerInfo = null; if (tileServerName.Equals(Properties.Resources.WMSMap, StringComparison.InvariantCultureIgnoreCase)) { using (var wmsDialog = new WMSServerParameters()) { if (wmsDialog.ShowDialog() != DialogResult.OK) { return; } 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 = new TileManager(tileServerName, tileServerUrl, wmsServerInfo); if (_bw.IsBusy != true) { _bw.RunWorkerAsync(); } else _bw.CancelAsync(); }