How do I load a basemap from rest services hosted on a local ArcGIS instance?

2084
1
Jump to solution
10-28-2019 10:03 AM
Labels (1)
PraveenaRaavicharla
New Contributor

How do I set it up so that the baseMap is loaded from my local ArcGIS instance using the following.

 

  var map = L.map('ui-map').setView([39, -97.5], 4);
  L.esri.basemapLayer('Streets').addTo(map);

0 Kudos
1 Solution

Accepted Solutions
FC_Basson
MVP Regular Contributor

What type of local layer are you trying to load as basemap? Tile layer, Vector Tile Layer, Map Image Layer, Image Service?  Layers are stacked in the order you add them, so the first layer you load will be the basemap.  You can use the dynamicMapLayer class to use a Map Image layer:

L.esri.dynamicMapLayer({
    url:'https://<myserver>/arcgis/rest/services/<map service>/MapServer',
    layers:[0]
 }).addToMap;‍‍‍‍

Alternatively you could add a Tile Layer as basemap using the Leaflet base classes.

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(map);

A handy way of handling multiple basemaps and overlays is by using the Leaflet layer control:

var basemaps = {
   "Esri Topographic": L.esri.basemapLayer('Topographic'),
   "OSM": L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(map)
};
var overlays = {
    "Streets": L.esri.dynamicMapLayer({
                 url:'https://<myserver>/arcgis/rest/services/<map service>/MapServer',
                 layers:[0]
               }),
    "Towns": L.esri.dynamicMapLayer({
               url:'https://<myserver>/arcgis/rest/services/<map service>/MapServer',
               layers:[1]
             })
};
L.control.layers(basemaps, overlays).addTo(map);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

0 Kudos
1 Reply
FC_Basson
MVP Regular Contributor

What type of local layer are you trying to load as basemap? Tile layer, Vector Tile Layer, Map Image Layer, Image Service?  Layers are stacked in the order you add them, so the first layer you load will be the basemap.  You can use the dynamicMapLayer class to use a Map Image layer:

L.esri.dynamicMapLayer({
    url:'https://<myserver>/arcgis/rest/services/<map service>/MapServer',
    layers:[0]
 }).addToMap;‍‍‍‍

Alternatively you could add a Tile Layer as basemap using the Leaflet base classes.

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(map);

A handy way of handling multiple basemaps and overlays is by using the Leaflet layer control:

var basemaps = {
   "Esri Topographic": L.esri.basemapLayer('Topographic'),
   "OSM": L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(map)
};
var overlays = {
    "Streets": L.esri.dynamicMapLayer({
                 url:'https://<myserver>/arcgis/rest/services/<map service>/MapServer',
                 layers:[0]
               }),
    "Towns": L.esri.dynamicMapLayer({
               url:'https://<myserver>/arcgis/rest/services/<map service>/MapServer',
               layers:[1]
             })
};
L.control.layers(basemaps, overlays).addTo(map);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos