private void LoadGeoServerLayer() { ktpsMap.MapUnit = GeographyUnit.DecimalDegree; WmsRasterLayer wmsRaster = new WmsRasterLayer(new Uri("http://192.168.1.149:8080/geoserver/topp/wms"), WebProxy.GetDefaultProxy()); wmsRaster.UpperThreshold = double.MaxValue; wmsRaster.LowerThreshold = 0; //http://localhost:8080/geoserver/topp/wms?service=WMS&version=1.1.0&request=GetMap&layers=topp:states&styles=&bbox=-124.73142200000001,24.955967,-66.969849,49.371735&width=780&height=330&srs=EPSG:4326&format=application/openlayers //http://localhost:8080/geoserver/cite/wms?service=WMS&version=1.1.0&request=GetMap&layers=Connecticut&styles=&bbox=-73.727962,40.984201,-71.786994,42.0520017&width=599&height=330&srs=EPSG:4326&format=application/openlayers //?service=WMS&version=1.1.0&request=GetMap&layers=Connecticut&styles=&bbox=-73.727962,40.984201,-71.786994,42.0520017&width=599&height=330&srs=EPSG:4326&format=application/openlayers wmsRaster.Crs = "EPSG:4326"; wmsRaster.Parameters.Add("service", "WMS"); wmsRaster.Parameters.Add("version", "1.1.0"); wmsRaster.Parameters.Add("request", "GetMap"); wmsRaster.Parameters.Add("layers", "topp:states"); wmsRaster.Parameters.Add("styles", ""); wmsRaster.Parameters.Add("bbox", "-124.73142200000001,24.955967,-66.969849,49.371735"); wmsRaster.Parameters.Add("srs", "EPSG:4326"); wmsRaster.Parameters.Add("format", "application/openlayers"); wmsRaster.Parameters.Add("width", ktpsMap.Width.ToString()); wmsRaster.Parameters.Add("height", ktpsMap.Height.ToString()); //wmsRaster.ActiveLayerNames.Add("topp:states"); wmsRaster.Name = "geoserver"; wmsRaster.OutputFormat = "image/png"; //wmsRaster.Credentials = new NetworkCredential("admin", "geoserver", "http://localhost:8080/geoserver/"); wmsRaster.Exceptions = "application/vnd.ogc.se_xml"; wmsRaster.TimeoutInSecond = 1000; if (wmsRaster.HasBoundingBox) { wmsRaster.Open(); foreach (string layerName in wmsRaster.GetServerLayerNames()) { wmsRaster.ActiveLayerNames.Add(layerName); } //ManagedProj4Projection proj4 = new ManagedProj4Projection(); //proj4.InternalProjectionParametersString = ManagedProj4Projection.GetDecimalDegreesParametersString(); //proj4.ExternalProjectionParametersString = ManagedProj4Projection.GetEpsgParsametersString(4326); //proj4.Open(); //proj4.ConvertToExternalProjection(wmsRaster.GetBoundingBox()); lblExtent.Text = "Upper Right X : " + wmsRaster.GetBoundingBox().UpperRightPoint.X.ToString(); lblExtent.Text += Environment.NewLine + "Upper Right Y : " + wmsRaster.GetBoundingBox().UpperRightPoint.Y.ToString(); lblExtent.Text += Environment.NewLine + "Lower Left X : " + wmsRaster.GetBoundingBox().LowerLeftPoint.X.ToString(); lblExtent.Text += Environment.NewLine + "Lower Left Y : " + wmsRaster.GetBoundingBox().LowerLeftPoint.Y.ToString(); ktpsMap.CurrentExtent = wmsRaster.GetBoundingBox(); wmsRaster.Close(); } // wmsRaster.Open(); LayerOverlay imageOverlay = new LayerOverlay(); imageOverlay.Layers.Add("GeoServerlayer", wmsRaster); // ktpsMap.CurrentExtent = wmsRaster.GetBoundingBox(); ktpsMap.Overlays.Add(imageOverlay); ktpsMap.CurrentScale = 5000000; //RectangleShape rshape = new RectangleShape(-124.73142200000001, 49.371735, -66.969849, 24.955967); //ktpsMap.CurrentExtent = rshape; lblExtent.Text += Environment.NewLine + Environment.NewLine; lblExtent.Text += "Map Extent"; lblExtent.Text += Environment.NewLine + "Upper Right X : " + ktpsMap.CurrentExtent.UpperRightPoint.X.ToString(); lblExtent.Text += Environment.NewLine + "Upper Right Y : " + ktpsMap.CurrentExtent.UpperRightPoint.Y.ToString(); lblExtent.Text += Environment.NewLine + "Lower Left X : " + ktpsMap.CurrentExtent.LowerLeftPoint.X.ToString(); lblExtent.Text += Environment.NewLine + "Lower Left Y : " + ktpsMap.CurrentExtent.LowerLeftPoint.Y.ToString(); //Feature f = new Feature(-95, 38); //ScreenPointF screenPoint = ExtentHelper.ToScreenCoordinate(new RectangleShape(-124.73142200000001, 49.371735, -66.969849, 24.955967), f, ktpsMap.Width, ktpsMap.Height); //ktpsMap.CenterAt(screenPoint); ktpsMap.Refresh(); }