One thing we’ve seen in the past with MS Access VBA (this may not be true in your case) is that you cannot piggy-back the COM calls. In other words, instead of
Set objProvider = Me.mapMain.Tiles.Providers
you may have to instead do something like
Dim objTiles as Tiles
Set objTiles = mapMain.Tiles
Set objProvider = objTiles.Providers
as stated in my last post (not published yet) I moved to MapWinGis WmsLayer functionality to display Wms-maps. The problem in my last try was, I got the extents mixed up (I accidentally swaped the X- and Y-Values).
Just to round this thread up - this is the code which did the Job:
' Test WMS
Dim objWmsLayer As MapWinGIS.WmsLayer
Dim objExtents As MapWinGIS.Extents
Dim intLayerHandle As Integer
Set objExtents = New MapWinGIS.Extents
Set objWmsLayer = New MapWinGIS.WmsLayer
objExtents.SetBounds 444247.640297, 5181048.300034, 0, 914153.8116, 5665064.52217, 0
objWmsLayer.BaseUrl = "https://www.lfu.bayern.de/gdi/wms/wasser/ueberschwemmungsgebiete"
objWmsLayer.BoundingBox = objExtents
objWmsLayer.DoCaching = False
objWmsLayer.Epsg = 25832
objWmsLayer.Format = "image/png"
objWmsLayer.Layers = "hwgf_hqhaeufig"
objWmsLayer.name = "Hochwassergefahrenfl?chen HQh?ufig"
objWmsLayer.Opacity = 63
objWmsLayer.UseCache = False
objWmsLayer.TransparentColor = 255
objWmsLayer.UseTransparentColor = True
intLayerHandle = Me.mapMain.addLayer(objWmsLayer, True)
Me.mapMain.LayerVisible intLayerHandle, True
Me.mapMain.Redraw
strange though, I implemented the code in my application after I have moved to MapWingis 5.2.4 and what used to work in 4.9.x in June doesn’t anymore.
The code doesn’t produce any errors but doesn’t show up the Wms-Layer either. So I guess somethings got messed up with the coordinates again by me. Strange though in the upper right corner of the map the coordinates displayed seem not to be EPSG 25832 but something like Mercator - I think I can remember they didn’t before.
As anybody any Idea?
Thanks in advance
for I was not sure whether it’s been kind of an MS-Access problem I created a small C# project with just one form and a map-Control . I put all the intelligence into the form load method (below). The code should load one shapefile (which it does) and display a wms layer (which it doesn’t).
The same as in Vba-code. No error-message but nothing shown either.
If someone wants to try out the code I could provide the shapefile.
The capabilities of the Wms-Layer can be found here:
Do I mix up the Coordinates? I’m pretty sure I don’t but numbers never been my strong side.
Thanks
I’ve started looking at this; I’ll need more time.
I know nothing about WMS layers, but I need to learn.
I do notice that the BoundingBox property indicates that it should be in the coordinate system of the server
That said, you are setting the EPSG to 4326, which is in degrees-minutes-seconds
but the bounding box properties you are setting look more like meters (UTM or Google Mercator)
Could this be why it’s not loading?
As a side note, the Shapefile you attached does load, but it has no DBF or projection file. The map control is likely defaulting to Google Mercator. There are settings to control the map projection as well as whether you want your layer to comply with the map, or the map to comply with the layer’s projection.
Well, I’ve made a few changes, trying different things, but still no success. Do you know the version of the WMS data? This affects the bounding box order. AND there may be a bug in the OCX related to the new v1.30, which changed the order (I think) to Lat,Long instead of Long,Lat.
private void Form1_Load(object sender, EventArgs e)
{
MapWinGIS.Shapefile objShape;
MapWinGIS.WmsLayer objWmsLayer;
MapWinGIS.Extents objExtents;
int intShapeHandle;
int intLayerHandle;
// tell the map we're using Google Mercator
axMap1.Projection = MapWinGIS.tkMapProjection.PROJECTION_GOOGLE_MERCATOR; // .PROJECTION_WGS84; //
axMap1.TileProvider = MapWinGIS.tkTileProvider.ProviderNone;
MapWinGIS.GlobalSettings gs = new MapWinGIS.GlobalSettings();
// tell the layer to use the Map's projection
gs.AllowLayersWithoutProjections = true;
gs.AllowProjectionMismatch = true;
gs.ReprojectLayersOnAdding = true;
objShape = new MapWinGIS.Shapefile();
// Shapefile laden
if (objShape.Open("C:\\Temp\\AX_Flurstueck\\AX_Flurstueck.shp", null))
{
intShapeHandle = this.axMap1.AddLayer(objShape, true);
// Hochwasser
objExtents = new MapWinGIS.Extents(); // objShape.Extents; //
objWmsLayer = new MapWinGIS.WmsLayer();
objWmsLayer.Version = MapWinGIS.tkWmsVersion.wvAuto;
objExtents.SetBounds(444247.640297, 5181048.300034, 0, 914153.8116, 5665064.52217, 0);
objWmsLayer.BaseUrl = "https://www.lfu.bayern.de/gdi/wms/wasser/ueberschwemmungsgebiete?";
objWmsLayer.BoundingBox = objExtents;
// the coordinates we're providing are in Google Mercator
objWmsLayer.Epsg = 3857; // 4326; //
objWmsLayer.Format = "image/png32";
objWmsLayer.Layers = "[hwgf_hqextrem]";
objWmsLayer.Name = "Hochwassergefahrenflächen HQhäufig";
objWmsLayer.Opacity = 63;
intLayerHandle = this.axMap1.AddLayer(objWmsLayer, true);
this.axMap1.set_LayerVisible(intLayerHandle, true);
this.axMap1.ZoomToLayer(intLayerHandle);
}
}
Let me know if you figure anything out, and I’ll do likewise.
i think, there is something wrong with this WMS-Service.
First, the ssl-certifacte it uses is self signed and not accepted from any application.
I just added this server address to QGis and MapInfo Pro and
it looks weired in both applications, you cannot zoom and it’s always only one view in one scale that shows up.
My first guess is a missconfigured wms server.