XYZ Esri

This example uses OpenLayers v4.0.1. The latest is v.

#### XYZ Esri

Example of a XYZ source using Esri tiles.

ArcGIS REST tile services are supported by `ol.source.XYZ`.

Related API documentation:

- ol.Attribution
,
- ol.Map
,
- ol.View
,
- ol.layer.Tile
,
- ol.proj
,
- ol.source.XYZ

Copy Edit
XYZ Esri Example of a XYZ source using Esri tiles. var attribution = new ol.Attribution({ html: 'Tiles © <a href="https://services.arcgisonline.com/ArcGIS/' + 'rest/services/World_Topo_Map/MapServer">ArcGIS</a>' }); var map = new ol.Map({ target: 'map', layers: [ new ol.layer.Tile({ source: new ol.source.XYZ({ attributions: [attribution], url: 'https://server.arcgisonline.com/ArcGIS/rest/services/' + 'World_Topo_Map/MapServer/tile/{z}/{y}/{x}' }) }) ], view: new ol.View({ center: ol.proj.fromLonLat([-121.1, 47.5]), zoom: 7 }) }); <div id="map" class="map"></div>

    <!DOCTYPE html>
    <html>
      <head>
        <title>XYZ Esri</title>
        <link rel="stylesheet" href="https://openlayers.org/en/v4.0.1/css/ol.css" type="text/css">
        <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
        <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
        <script src="https://openlayers.org/en/v4.0.1/build/ol.js"></script>
      </head>
      <body>
        <div id="map" class="map"></div>
        <script>
          var attribution = new ol.Attribution({
            html: 'Tiles © <a href="https://services.arcgisonline.com/ArcGIS/' +
                'rest/services/World_Topo_Map/MapServer">ArcGIS</a>'
          });

          var map = new ol.Map({
            target: 'map',
            layers: [
              new ol.layer.Tile({
                source: new ol.source.XYZ({
                  attributions: [attribution],
                  url: 'https://server.arcgisonline.com/ArcGIS/rest/services/' +
                      'World_Topo_Map/MapServer/tile/{z}/{y}/{x}'
                })
              })
            ],
            view: new ol.View({
              center: ol.proj.fromLonLat([-121.1, 47.5]),
              zoom: 7
            })
          });
        </script>
      </body>
    </html>