2

I'm relatively new to the ArcGIS JS API, but I'm looking to use the OS Open Background as the basemap. I'm using the latest (4.0) API and I can't find a working example or decent documentation that describes the process. I can find enough for v3.16, but nothing that also applies to 4.

I'm currently trying something like this:

layerUrl = "https://tiles.arcgis.com/tiles/qHLhLQrcvEnxjtPr/arcgis/rest/services/OS_Open_Background_2/MapServer",
layer = new TileLayer(layerUrl, {
 tileServers: ["https://tiles1.arcgis.com/tiles/qHLhLQrcvEnxjtPr/arcgis/rest/services/OS_Open_Background_2/MapServer", "https://tiles2.arcgis.com/tiles/qHLhLQrcvEnxjtPr/arcgis/rest/services/OS_Open_Background_2/MapServer", "https://tiles3.arcgis.com/tiles/qHLhLQrcvEnxjtPr/arcgis/rest/services/OS_Open_Background_2/MapServer", "https://tiles4.arcgis.com/tiles/qHLhLQrcvEnxjtPr/arcgis/rest/services/OS_Open_Background_2/MapServer"]
});
map.add(layer);

...but this just causes the browser to hang indefinitely before crashing, so something isn't responding as expected or the URLs aren't correct. Any pointers?

Kirk Kuykendall
25.9k9 gold badges68 silver badges155 bronze badges
asked Jun 27, 2016 at 13:03
2
  • Do you receive an error message or anything in the log file? Commented Jun 27, 2016 at 13:19
  • Nothing - the browser just hangs and then Chrome crashes. Nothing in the dev tools log, no. Commented Jun 27, 2016 at 13:20

1 Answer 1

2

From the documentation:

Known Limitations
When adding an TileLayer to a map in a SceneView, the following limitations exist:
If viewingMode is global, then only services with a Web Mercator spatial reference (wkid 3857) are supported.
If viewingMode is local, then only services with projected coordinate systems are supported.
Only Tile layers with the following tiling scheme specifications are supported:
256x256 pixel tiles
Scale levels must increase or decrease by a power of two
At level 0 there shouldn't be more than 30 root tiles.
All tiled layers must have the same tiling scheme and SpatialReference.

The limitition is for the 3D. This is the code to work with 2D:

<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
 <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
 <title>Get started with SceneView - Create a 3D map - 4.0</title>
 <style>
 html,
 body,
 #viewDiv {
 padding: 0;
 margin: 0;
 height: 100%;
 width: 100%;
 }
 </style>
 <link rel="stylesheet" href="https://js.arcgis.com/4.0/esri/css/main.css">
 <script src="https://js.arcgis.com/4.0/"></script>
 <script>
 require([
 "esri/Map",
 "esri/layers/TileLayer",
 "esri/views/SceneView",
 "dojo/domReady!"
 ], function(Map, TileLayer, SceneView) {
 var map = new Map();
 var layerUrl = "https://tiles.arcgis.com/tiles/qHLhLQrcvEnxjtPr/arcgis/rest/services/OS_Open_Background_2/MapServer";
 var layer = new TileLayer(layerUrl, {
 tileServers: ["https://tiles1.arcgis.com/tiles/qHLhLQrcvEnxjtPr/arcgis/rest/services/OS_Open_Background_2/MapServer", "https://tiles2.arcgis.com/tiles/qHLhLQrcvEnxjtPr/arcgis/rest/services/OS_Open_Background_2/MapServer", "https://tiles3.arcgis.com/tiles/qHLhLQrcvEnxjtPr/arcgis/rest/services/OS_Open_Background_2/MapServer", "https://tiles4.arcgis.com/tiles/qHLhLQrcvEnxjtPr/arcgis/rest/services/OS_Open_Background_2/MapServer"]
 });
 map.add(layer);
 var view = new SceneView({
 container: "viewDiv",
 viewingMode: "local",
 map: map
 });
 });
 </script>
</head>
<body>
 <div id="viewDiv"></div>
</body>
</html>
answered Jun 27, 2016 at 13:24
3
  • 1
    ...so are you saying that the OS maps are not compatible with v4 of the JS API at this stage? I'm not sure how I can check those maps have those limitations? Commented Jun 27, 2016 at 13:57
  • 1
    Look at the Service Description. The Spatial Reference is 27700... Commented Jun 27, 2016 at 14:06
  • 1
    Openlayers 3 example to get around the limitation jsfiddle.net/goldrydigital/r0kqdwan Commented Jun 27, 2016 at 15:08

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.