Reimers.dk

.NET, AJAX and Google APIs brought together
Welcome to Reimers.dk Sign in | Join | Help

How to add a WMS layer?

  •  09-14-2009, 16:43

    How to add a WMS layer?

    Hi

    I'm new to the .Net GoogleMaps control and have been experimenting with adding a WMS layer on top of a google map. I've figured out how to add the WMSTileLayer, but it's not showing my WMS layer, which I know is working.

    The code is as follows:

    WMSTileLayer wmslayer = new WMSTileLayer("wmslayer");
    List<String> urlList = new List<String>();
    urlList.Add(
    "http://mywebsite:8080/geoserver/wms?");
    wmslayer.BaseUrls = urlList;
    wmslayer.Layers =
    "gispro:osm_roads";
    wmslayer.Format =
    "image/png";
    wmslayer.Version =
    "1.1.1";
    wmslayer.MinZoomLevel = 0;
    wmslayer.MaxZoomLevel = 17;
    wmslayer.IsPng =
    true;
    wmslayer.ID =
    "wmslayer";

    NormalMapTileLayer normTileLayer = new NormalMapTileLayer();
    CustomMapType custMapType = new CustomMapType();
    custMapType.Layers.Clear();
    custMapType.ID =
    "cmt";
    custMapType.Name =
    "Test";
    custMapType.Layers.Add(normTileLayer);
    custMapType.Layers.Add(wmslayer);

    map.Options.MapTypes.Clear();
    map.Options.MapTypes.Add(custMapType);

    This creates the custom map type, but all I get is the google background with no WMS layer. I can't tell why it's not working because I can't find the WMS request that's being generated in order to check if it's correct.

    Has anyone else had success with overlaying a WMS layer over GoogleMaps with the WMSTileLayer class?

    Regards

    John

    Filed under: , ,
View Complete Thread