# AddLayer strange behaviour

**URL:** <https://mapwindow.discourse.group/t/addlayer-strange-behaviour/857>\
**Category:** MapWinGIS\
**Created:** [January 5, 2021, 5:19pm UTC](https://mapwindow.discourse.group/t/addlayer-strange-behaviour/857 "2021-01-05T17:19:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MAX](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@MAX](https://mapwindow.discourse.group/u/MAX)\
**Post date:** [January 5, 2021, 5:19pm UTC](https://mapwindow.discourse.group/t/addlayer-strange-behaviour/857/1 "2021-01-05T17:19:18Z")

</div>

Dim intLayerHandle As Integer = AxMap1.AddLayer(objWmsLayer, True)  
please explain me in that cases intLayerHandle is -1 (error)  
I tried with a typo in baseurl but the result is always greater than -1  
so i can’t understand if it’s really an error

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [January 5, 2021, 7:56pm UTC](https://mapwindow.discourse.group/t/addlayer-strange-behaviour/857/2 "2021-01-05T19:56:41Z")

</div>

Hello @MAX

Are you saying that you always get a Handle greater than -1, but there is still an error?

It’s possible, perhaps, with the WMS layer, that the layer object might be added successfully, returning a valid layer handle, but that there is still something wrong internally with the WMS layer itself, which might cause it not to display (including an invalid URL).

Regards,  
Jerry.

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [January 5, 2021, 10:01pm UTC](https://mapwindow.discourse.group/t/addlayer-strange-behaviour/857/3 "2021-01-05T22:01:41Z")

</div>

Just as a follow-up, you can look at the Global or WMS-specific error after trying to load the layer. Something like:

```
objWmsLayer.ErrorMsg(objWmsLayer.LastErrorCode)
```

---

<div class="post-metadata">

**Author:** ![MAX](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@MAX](https://mapwindow.discourse.group/u/MAX)\
**Post date:** [January 6, 2021, 7:41am UTC](https://mapwindow.discourse.group/t/addlayer-strange-behaviour/857/4 "2021-01-06T07:41:55Z")

</div>

I try now  
thanks @jerryfaust

…yes, map control don’t display the wms  
can you help me? can you try to solve for me?  
here il an example:  
[https://wms.cartografia.agenziaentrate.gov.it/inspire/wms/ows01.php?service=WMS&request=GetMap&layers=CP.CadastralParcel&styles=&format=image%2Fpng&transparent=true&version=1.1.1&width=256&height=256&srs=EPSG%3A6706&bbox=10.350494384765627,44.788657917188125,10.351867675781252,44.78963254761407](https://wms.cartografia.agenziaentrate.gov.it/inspire/wms/ows01.php?service=WMS&request=GetMap&layers=CP.CadastralParcel&styles=&format=image%2Fpng&transparent=true&version=1.1.1&width=256&height=256&srs=EPSG%3A6706&bbox=10.350494384765627,44.788657917188125,10.351867675781252,44.78963254761407)  
and getcapabilities:  
[https://wms.cartografia.agenziaentrate.gov.it/inspire/wms/ows01.php?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities](https://wms.cartografia.agenziaentrate.gov.it/inspire/wms/ows01.php?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities)  
[https://wms.cartografia.agenziaentrate.gov.it/inspire/wms/ows01.php?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities](https://wms.cartografia.agenziaentrate.gov.it/inspire/wms/ows01.php?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities)

---

<div class="post-metadata">

**Author:** ![MAX](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@MAX](https://mapwindow.discourse.group/u/MAX)\
**Post date:** [January 6, 2021, 9:12am UTC](https://mapwindow.discourse.group/t/addlayer-strange-behaviour/857/5 "2021-01-06T09:12:42Z")

</div>

It says “No Error” (I tried with typo error in baseurl, wrong bbox, wrong epsg, wrong version… same message)

this is MW5 with wms:

 ![mw5](https://global.discourse-cdn.com/free1/uploads/mapwindow1/original/1X/8007a785fefe93e13b20a10bfcf327080101a493.jpeg)  
I see inverted coordinates plus a bad visualization 🙂  
by the way…  
this is extracted from 1.1.1 getcapabilities:

> LatLonBoundingBox minx=“2” miny=“33” maxx=“19” maxy=“48”  
> BoundingBox SRS=“EPSG:6706” minx=“2” miny=“33” maxx=“19” maxy=“48”

and this from 1.3.0:

> EX\_GeographicBoundingBox  
> westBoundLongitude 2 westBoundLongitude  
> eastBoundLongitude 19 eastBoundLongitude  
> southBoundLatitude 33 southBoundLatitude  
> northBoundLatitude 48 northBoundLatitude  
> /EX\_GeographicBoundingBox  
> BoundingBox CRS=“EPSG:6706” minx=“33” miny=“2” maxx=“48” maxy=“19”

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [January 5, 2022, 2:13pm UTC](https://mapwindow.discourse.group/t/addlayer-strange-behaviour/857/6 "2022-01-05T14:13:23Z")

</div>

Sorry for the late reply.

I see your map projection (WGS84) isn’t the same as the WMS projection (EPSG:6706).  
Try to match them first.

And I’ve seen posts here about adding WMS layers and they had to switch the min and max values.  
You could try that as well.
