3

I'm just starting with the ArcGIS Javascript API, and I'm having some issues adding layers from my geoserver to my basic map application.

I started with the WMS resource info sample from the ESRI site (https://developers.arcgis.com/javascript/jssamples/layers_wmsresourceinfo.html). I took out the two layers they display in that sample, and I replaced it with a WMS layer from my geoserver. I'm getting this error:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE ServiceExceptionReport SYSTEM "http://mygeoserver.com/geoserver/schemas/wms/1.1.1/WMS_exception_1_1_1.dtd"> <ServiceExceptionReport version="1.1.1" > <ServiceException code="InvalidSRS">
 Error occurred decoding the espg code EPSG:102100
No code &quot;EPSG:102100&quot; from authority &quot;European Petroleum Survey Group&quot; found for object of type &quot;IdentifiedObject&quot;.
</ServiceException></ServiceExceptionReport>

The problem seems to stem from the difference in spatial references. The base map uses 102100, and my layer uses 4326. It doesn't look like changing the spatial reference of my layer is an option, so is it possible for me to change the spatial reference of the base map?


I added 102100 as a custom CRS to my geoserver. I then changed the declared SRS for my layer to EPSG:3857, and told it to "reproject native to declared" (I'm also new to using geoserver, so please let me know if it sounds like I'm doing something wrong there). I'm getting a different error message now:

<ServiceExceptionReport xmlns="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.3.0" xsi:schemaLocation="http://www.opengis.net/ogc http://localhost:8040/geoserver/schemas/wms/1.3.0/exceptions_1_3_0.xsd">
<ServiceException code="InvalidCRS">
Error occurred decoding the espg code urn:x-ogc:def:crs:EPSG:102100 Error in "PROJECTION": No transform for classification "Mercator_Auxiliary_Sphere". Error in "PROJECTION": No transform for classification "Mercator_Auxiliary_Sphere". No transform for classification "Mercator_Auxiliary_Sphere".
</ServiceException>
</ServiceExceptionReport>

And for full information, here's the js code of my basic ArcGIS map:

var map;
require([
 'esri/map', 'esri/layers/WMSLayer', 'esri/layers/WMSLayerInfo', 'esri/geometry/Extent',
 'dojo/_base/array', 'dojo/dom', 'dojo/dom-construct', 'dojo/parser',
 'dijit/layout/BorderContainer', 'dijit/layout/ContentPane', 'dojo/domReady!'
], function(Map, WMSLayer, WMSLayerInfo, Extent, array, dom, domConst, parser) {
 parser.parse();
 map = new Map('map', {
 basemap: 'hybrid',
 center: [-96, 37],
 zoom: 4
 });
 var layer1 = new WMSLayerInfo({
 name: 'states',
 title: 'states'
 });
 var resourceInfo = {
 extent: new Extent(-120.77027961360125 ,35.79436009671527, -120.74876891832204, 35.81224289313929, {
 wkid: 3857
 }),
 layerInfos: [layer1]
 };
 var wmsLayer = new WMSLayer('http://localhost:8040/geoserver/topp/wms', {
 resourceInfo: resourceInfo,
 visibleLayers: ['states']
 });
 map.addLayers([wmsLayer]);
 var details = dom.byId('details');
 domConst.place('<b>Layers</b>:', details);
 var ul = domConst.create('ul', null, details);
 array.forEach(wmsLayer.layerInfos, function(layerInfo) {
 domConst.create('li', { innerHTML: layerInfo.title }, ul);
 });
 domConst.place('<b>WMS Version</b>:' + wmsLayer.version + '<br />', details);
});

Any idea what might be causing the error?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Mar 31, 2015 at 20:50
2
  • depends if it is defined on the service this example sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/… there are 2 CRS options CRS:84 or EPSG:4326 Commented Mar 31, 2015 at 21:01
  • The layer on my geoserver is defined the same way. The basemap I'm using is just the ESRI "streets" map. Not sure how that is defined. Commented Mar 31, 2015 at 21:11

3 Answers 3

4

So I finally found the solution to this problem. You have to override the spatialReferences array of the WMSLayer object right before adding it to the map.

 wmsLayer.spatialReferences[0] = 3857;
 map.addLayers([wmsLayer]);

This worked with a layer using EPSG:3857 and another layer using ESPG:4326.

answered Apr 13, 2015 at 13:44
2

What Mintx has said is correct but to expand and answer your specific question about the base map SRef...

It's not possible to change the SRef of a tiled map service, which all of the ESRI base maps are (and I would imagine most base maps are). This is because the tiles have already been created in the specified SRef.

The basemap you use sets the spatial reference your map will use. All layers you add on top must be in the same spatial reference or support re-projection.

WMS layers can be configured to support re projection to other spatial references.

However, if you're using an ESRI basemap (SRef 3857 / 102100 - see note below) and your WMS service only supports SRef 4326, it is not possible to add it to the map. If you have control of the WMS service the best option is to add 3857 as a supported SRef. If not, I have heard it might be possible to use another product that can proxy requests to WMS services and dynamically re-project them from one SRef to another, but I don't have any experience of this.

A note on Web Mercator (or Spherical Mercator) spatial reference codes. Codes 3857, 102100, 102113 and 900913 all refer to the same projection. ESRI coined the 102100 and 102113 ones while (削除) Google (削除ここまで) the OpenLayers team coined 900913 (which can be read as google!). This was prior to there being an official EPSG code for this projection. The EPSG then assigned this projection code 3857.

If you add an ESRI base map (102100) the map will show SRef 3857 and you will be able to add WMS layers that support 3857.

answered Apr 1, 2015 at 7:21
3
  • Minor correction: EPSG:900913 was coined by the OpenLayers team, and not google. See: crschmidt.net/blog/archives/243/google-projection-900913 Commented Apr 1, 2015 at 9:30
  • Ah thanks! I almost wrote something along the lines of this being based on information I've pieced together over time and not necessarily completely correct, so thanks for adding that. Commented Apr 1, 2015 at 11:23
  • Thanks Simon and Mintx! This is the exact information I was looking for. So I added 102100 as a custom CRS to my geoserver, and I then reprojected my layer to 3857. And I'm still getting a similar error. Looks like I'm going to run out of space if I try to paste it here, so I'll edit my original post with my new questions. Commented Apr 1, 2015 at 15:19
2

It looks like the EPSG code on your geoserver is incorrect. 102100 is not an EPSG code; that's an ESRI code. 3857 is the EPSG equivalent.

You'll need to somehow define the SRID on your geoserver as 102100:ESRI or 3857:EPSG.

edit: It looks like you just need to assign the right WKID (4326) to your WMS layer:

 var resourceInfo = {
 extent: new Extent(-120.77027961360125 ,35.79436009671527, -120.74876891832204, 35.81224289313929, {
 wkid: 4326 
 }),
 layerInfos: [layer1]
 };
answered Mar 31, 2015 at 21:27
2
  • I tried that (and changed the extent accordingly), and I get this error now: <ServiceException code="InvalidCRS"> Error occurred decoding the espg code urn:x-ogc:def:crs:EPSG:102100 No code "EPSG:102100" from authority "European Petroleum Survey Group" found for object of type "IdentifiedObject". </ServiceException> Commented Apr 3, 2015 at 18:47
  • This sounds like an issue with the geoserver's ability to decode ESRI:102100. I added 102100 as a custom CRS to my geoserver, but it added it as EPSG:102100, which is invalid. Commented Apr 3, 2015 at 18:50

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.