protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Map1.MapUnit = GeographyUnit.Meter; Map1.CurrentExtent = new RectangleShape(-700000, 6557681, 1251120, 4909089); Map1.MapTools.Logo.Enabled = false; Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean); Map1.MapTools.OverlaySwitcher.Enabled = true; Map1.MapTools.OverlaySwitcher.BackgroundColor = new GeoColor(50, GeoColor.StandardColors.White); Map1.MapTools.OverlaySwitcher.RoundedCornerColor = new GeoColor(50, GeoColor.StandardColors.White); Map1.MapTools.OverlaySwitcher.BaseOverlayTitle = "Choix du fond de carte:"; Map1.MapTools.OverlaySwitcher.DynamicOverlayTitle = "
Affichage des calques:"; LayerOverlay emptyLayerOverlay = new LayerOverlay("emptyLayerOverlay"); emptyLayerOverlay.Name = "Aucun"; emptyLayerOverlay.IsBaseOverlay = true; emptyLayerOverlay.SetBaseEpsgProjection("EPSG:900913"); // Spherical Mercator Map1.CustomOverlays.Add(emptyLayerOverlay); GoogleOverlay googleMapsOverlay = new GoogleOverlay("googleMapsOverlay"); googleMapsOverlay.Name = "Google Maps"; googleMapsOverlay.GoogleMapType = GoogleMapType.Hybrid; googleMapsOverlay.IsBaseOverlay = true; Map1.CustomOverlays.Add(googleMapsOverlay); Key = "your key" username = "user name"; password = "PWD"; string layerID = "CP.CadastralParcel"; string layerCRS = "EPSG:2154"; Uri IGNuri = new Uri("base url" + Key + "/inspire/r/wms"); string layerName = "Cadastre"; float layerOpacity = 0.5F; bool layerIsBaseOverlay = false; LayerOverlay IGNLayerOverlay = new LayerOverlay("IGN_" + layerID, layerIsBaseOverlay, TileType.SingleTile); IGNLayerOverlay.Name = layerName; IGNLayerOverlay.Opacity = layerOpacity; IGNLayerOverlay.IsVisible = true; WmsRasterLayer IGNWmsRasterLayer = new WmsRasterLayer(IGNuri); ((WmsRasterSource)IGNWmsRasterLayer.ImageSource).SendingWebRequest += new EventHandler(IGNWmsRasterLayer_SendingRequest); IGNWmsRasterLayer.Crs = layerCRS; IGNWmsRasterLayer.Parameters.Add("SERVICE", "WMS"); IGNWmsRasterLayer.Parameters.Add("LAYERS", layerID); IGNWmsRasterLayer.Parameters.Add("STYLES", "inspire_common:DEFAULT"); IGNWmsRasterLayer.Parameters.Add("FORMAT", "image/png"); IGNWmsRasterLayer.Parameters.Add("WIDTH", "256"); IGNWmsRasterLayer.Parameters.Add("HEIGHT", "256"); IGNWmsRasterLayer.Parameters.Add("CRS", layerCRS); IGNWmsRasterLayer.Parameters.Add("VERSION", "1.3.0"); IGNWmsRasterLayer.ImageSource.Open(); foreach (string name in IGNWmsRasterLayer.GetServerLayerNames()) { IGNWmsRasterLayer.ActiveLayerNames.Add(name); } IGNWmsRasterLayer.ImageSource.Close(); Proj4Projection proj = new Proj4Projection(); proj.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(2154); proj.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString(); proj.Open(); (IGNWmsRasterLayer.ImageSource as WmsRasterSource).Projection = proj; IGNLayerOverlay.Layers.Add(IGNWmsRasterLayer); Map1.CustomOverlays.Add(IGNLayerOverlay); } } protected void IGNWmsRasterLayer_SendingRequest(object sender, SendingWebRequestEventArgs e) { string url = e.WebRequest.RequestUri.OriginalString.Replace("http://", "https://"); e.WebRequest = WebRequest.Create(new Uri(url)); e.WebRequest.Credentials = new NetworkCredential(username, password); }