MapEngine engine = new MapEngine();
engine.CurrentExtent = ExtentHelper.GetDrawingExtent(CommonExtents.Europe, width, height);
WmsRasterLayer wmsRasterLayer = new WmsRasterLayer(new Uri(“localhost:8080/service?”));
wmsRasterLayer.UpperThreshold = double.MaxValue;
wmsRasterLayer.LowerThreshold = 0;
wmsRasterLayer.Open();
foreach (string layer_name in wmsRasterLayer.GetServerLayerNames())
{
wmsRasterLayer.ActiveLayerNames.Add(layer_name);
}
// GetRequestUrl for debug
string requestUrl = wmsRasterLayer.GetRequestUrl(engine.CurrentExtent, width, height);
System.Diagnostics.Debug.WriteLine(requestUrl);
wmsRasterLayer.Close();
engine.StaticLayers.Add(“wmsImageLayer”, wmsRasterLayer);
Bitmap bitmap = new Bitmap(width, height);
engine.OpenAllLayers();
engine.DrawStaticLayers(bitmap, GeographyUnit.Meter);
engine.CloseAllLayers();
What I’m after is the moral equivalent of this OpenLayers code.
map = new OpenLayers.Map(‘map’, {
maxResolution: 156543.033928,
maxExtent: new OpenLayers.Bounds(-20037508.3428, -20037508.3428, 20037508.3428,
20037508.3428),
projection: new OpenLayers.Projection(“EPSG:3857”)
});
var layer = new OpenLayers.Layer.WMS( “WMS gm_layer”,
“…/service?”,
{layers: “gm_layer”, format: “image/png”, srs:“EPSG:3857”,
exceptions: “application/vnd.ogc.se_inimage”, transparent: true},
{singleTile: true, ratio: 1, isBaseLayer: true} );
map.addLayer(layer);
Specify CRS with WmsRasterLayer
Hi Jeremy,
In WmsRasterLayer, there is a property "Crs" to define the target epsg in the server. Some partial codes like this:
WmsRasterLayer wmsImageLayer = new WmsRasterLayer(new Uri("localhost:8080/service?"));
wmsImageLayer.SendingWebRequest += new EventHandler<sendingwebrequesteventargs>(wmsImageLayer_SendingWebRequest);
wmsImageLayer.UpperThreshold = double.MaxValue;
wmsImageLayer.LowerThreshold = 0;
wmsImageLayer.Crs = "EPSG:3857";
The SendingWebRequest event is register to help us to see the request information.
Hope it helps and if there is anything i misunderstand, please feel free to correct me.
Thanks,
Troy</sendingwebrequesteventargs>
Hi Jeremy,
In WmsRasterLayer, there is a property "Crs" to define the target epsg in the server. Some partial codes like this:
WmsRasterLayer wmsImageLayer = new WmsRasterLayer(new Uri("localhost:8080/service?"));
wmsImageLayer.SendingWebRequest += new EventHandler<SendingWebRequestEventArgs>(wmsImageLayer_SendingWebRequest);
wmsImageLayer.UpperThreshold = double.MaxValue;
wmsImageLayer.LowerThreshold = 0;
wmsImageLayer.Crs = "EPSG:3857";
The SendingWebRequest event is register to help us to see the request information.
Besides, please make sure the base projection is also under the mercator.
Hope it helps and if there is anything i misunderstand, please feel free to correct me.
Thanks,
Troy