Select to view content in your preferred language

Using Custom Basemaps with Default Zoom Widget

1802
11
03-26-2019 07:31 AM
BenRomlein
Occasional Contributor

I'm using a TileLayer to create a Basemap for my JavaScript 4.10 app:

var streetsTile = new TileLayer({ url: "https://myserver/arcgis/rest/.../MapServer", });

var streetsBase = new Basemap({ baseLayers: [streetsTile] });

var map = new Map({
   basemap: streetsBase
});

var view = new MapView({
   container: 'mapView',
   map: map,
});

With this code, the default zoom widget doesn't work to zoom in at the outermost scale. After I zoom in once (with mouse wheel or double click) I can zoom in or out using the widget. If I zoom back to the outermost scale, I have to zoom in once with another method before the widget will work again. Using Esri basemaps, the widget functions normally, so the problem is related to my basemap.

What is causing this behavior? How can I correct it so the widget will work at all zoom levels?

I've tried creating a TileInfo and using its lods as a constraints for my view:

var myInfo = TileInfo.create({
   origin: new Point({
      spatialReference: streetsTile.spatialReference,
      x: -5120900.0,
      y: 9998100.0

      }),
   spatialReference: streetsTile.spatialReference,
   scales: [2500000, 1000000, 500000, 250000, 125000, 64000, 32000, 16000, 8000, 4000, 2000, 1000]
});

var view = new MapView({
   container: 'mapView',
   map: map,
   constraints: {
      lods: myInfo.lods
   }
});

But this does not resolve the problem. If I remove the scales property from my TileInfo and use the default scales, the widget will work but I don't want that many scales in my app.

How can I make the zoom widget work with my basemap while still limiting the scales to only the levels I have cached?

0 Kudos
11 Replies
BenRomlein
Occasional Contributor

I've tried switching the lods array around, but the problem persists. 

  var lods = [{
"level": 0,
"resolution": 0.26458386250105836,
"scale": 1000
}, {
"level": 1,
"resolution": 0.5291677250021167,
"scale": 2000
}, {
"level": 2,
"resolution": 1.0583354500042335,
"scale": 4000
}, {
"level": 3,
"resolution": 2.116670900008467,
"scale": 8000
}, {
"level": 4,
"resolution": 4.233341800016934,
"scale": 16000
}, {
"level": 5,
"resolution": 8.466683600033868,
"scale": 32000
}, {
"level": 6,
"resolution": 16.933367200067735,
"scale": 64000
}, {
"level": 7,
"resolution": 33.0729828126323,
"scale": 125000
}, {
"level": 8,
"resolution": 66.1459656252646,
"scale": 250000
}, {
"level": 9,
"resolution": 132.2919312505292,
"scale": 500000
}, {
"level": 10,
"resolution": 264.5838625010584,
"scale": 1000000
}, {
"level": 11,
"resolution": 661.4596562526459,
"scale": 2500000
}];

Bug report time? It's just strange to me that no one else seems to experience this glitch. I've also tried defining the max/min scales, spatialReference, and server version when I create the TileLayer, but none of that seems to make a difference either:

var streetsTile = new TileLayer({
   url: "http://myserver/arcgis/rest/services/Basemaps/Streets/Mapserver",
   minScale: 1000,
   maxScale: 2500000,
   version: 10.4,
   spatialReference: {wkid: 26916}

});

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Yep, time to contact tech support.

0 Kudos