Select to view content in your preferred language

How to Get TileLayer in 4.3?It's work in 3.20

1800
4
06-04-2017 11:00 PM
tangms
by
Emerging Contributor

Dear Sir:

I want to load a tilelayer map in 4.3 . my code like this:

<!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 MapView - Create a 2D map</title>
<style>
html, body, #viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.3/esri/css/main.css">
<script src="https://js.arcgis.com/4.3/"></script>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/TileLayer",
"dojo/domReady!"
], function(Map, MapView,TileLayer){

// URL points to a cached tiled map service hosted on ArcGIS Server
var operationalLayer = new TileLayer({
url: "http://www.digitalcq.com/RemoteRest/services/CQMap_IMG/MapServer"
});
var map = new Map({

});
map.layers.add(operationalLayer);

var view = new MapView({
container: "viewDiv", // Reference to the scene div created in step 5
map: map // Reference to the map object created before the scene
//zoom: 4, // Sets the zoom level based on level of detail (LOD)
//center: [15, 65] // Sets the center point of view in lon/lat
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>

it's doesn't work with any error;

But ,this work in 3.20 like this:

map = new Map("map",{

});

var tiled = new ArcGISTiledMapServiceLayer("http://www.digitalcq.com/RemoteRest/services/CQMap_IMG/MapServer");
map.addLayer(tiled);

Why? and how to change?

need u help!

Tags (2)
0 Kudos
4 Replies
JayantaPoddar
MVP Esteemed Contributor

Could you check TileLayer | API Reference | ArcGIS API for JavaScript 4.3 ?

There might have been a few changes from ver. 4.0 and later.



Think Location
KenBuja
MVP Esteemed Contributor

Are you sure that's the correct URL for the tile layer? I get a redirect when trying to access it. Your code works correctly when using one of the Esri tile services

<!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 MapView - Create a 2D map</title>
  <style>
    html, body, #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }
  </style>
  <link rel="stylesheet" href="https://js.arcgis.com/4.3/esri/css/main.css">
  <script src="https://js.arcgis.com/4.3/"></script>
  <script>
    require([
    "esri/Map",
    "esri/views/MapView",
    "esri/layers/TileLayer",
    "dojo/domReady!"
    ], function (Map, MapView, TileLayer) {

      // URL points to a cached tiled map service hosted on ArcGIS Server
      var operationalLayer = new TileLayer({
        url: "https://services.arcgisonline.com/arcgis/rest/services/Demographics/USA_Percent_Under_18/MapServer"
      });
      var map = new Map({

      });
      map.layers.add(operationalLayer);

      var view = new MapView({
        container: "viewDiv", // Reference to the scene div created in step 5
        map: map // Reference to the map object created before the scene
        //zoom: 4, // Sets the zoom level based on level of detail (LOD)
        //center: [15, 65] // Sets the center point of view in lon/lat
      });
    });
  </script>
</head>
<body>
  <div id="viewDiv"></div>
</body>
</html>
tangms
by
Emerging Contributor

Yes,the url is correct .but esri forum's extranl url will be redirect. 

I check the server,this version is 10.0.2,and ver 4.3 only support 10.3 or later.

anybody can solve this problem?

0 Kudos
PramudyaSeptian
Deactivated User

i am experiencing the same problem. However, i am using arcgis server 10.4. My code also didnt work when it was referring to my local tiled map service but worked when i changed it into ESRI or other server tiled map service.

Definitely confusing, my guess is that it is not with the code instead there is something wrong with the server configuration or what.

Please help

0 Kudos