OpenLayers and ArcGIS location services

OpenLayers is a JavaScript library for making interactive maps. This guide contains tutorials to help you start working with OpenLayers and ArcGIS location services to develop a number of different types of mapping applications.

Audience: Developers building mapping, location-based, and spatial analysis solutions.

Maps

Learn how to create and display maps with basemap layers.

Layers

Learn how to add different types of data layers to maps.

Query and edit

Learn how to work with feature layers and feature services.

Style and data visualization

Learn how to style data layers and basemap layers for maps.

Geocode and search

Learn how to find addresses, businesses, and places with the geocoding service.

Route and directions

Learn how to find a route and directions and service areas with the routing service.

Demographic data

Learn how to get demographic data with the GeoEnrichment service.

Get started

To start building applications with location services, you need an account and an API key.

1. Sign in with your ArcGIS account

Access the developer dashboard and tools you need to start building applications.

Get a free developer account

2. Start with an API key

The ArcGIS Platform supports different authentication methods. You can use an API key or OAuth 2.0 access token; we recommend starting with an API key. Learn more in Security and authentication.

Get an API key

3. Quick start

Below is a simple example that shows how to create a map with OpenLayers and the basemap layer service.

To build this map:

  1. Open the code in .

  2. Replace the apiKey with your API key from the dashboard.

    Change line
                                                        
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    <html>
      <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
        <title>OpenLayers Tutorials: Display a map</title>
    
        <style>
          html,
          body,
          #map {
            padding: 0;
            margin: 0;
            height: 100%;
            width: 100%;
            font-family: Arial, Helvetica, sans-serif;
            font-size: 14px;
            color: #323232;
        </style>
    
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.4.3/css/ol.css" type="text/css" />
        <script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.4.3/build/ol.js"></script>
    
        <script src="https://cdn.jsdelivr.net/npm/ol-mapbox-style@6.1.4/dist/olms.js"></script>
    
      </head>
      <body>
        <div id="map"></div>
    
        <script>
    
          const map = new ol.Map({ target: "map" });
    
          map.setView(
            new ol.View({
              center: ol.proj.fromLonLat([-25, 25]), // Starting location [longitude, latitude]
              zoom: 2
            })
          );
    
          const apiKey = "YOUR_API_KEY";
    
          const basemapId = "ArcGIS:Navigation";
    
          const basemapURL = "https://basemaps-api.arcgis.com/arcgis/rest/services/styles/" + basemapId + "?type=style&token=" + apiKey;
    
          olms(map, basemapURL);
    
        </script>
    
      </body>
    </html>

4. Tutorials

Follow step-by-step tutorials to learn more about how to integrate OpenLayers with other location services.

See all tutorials

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.