Class OpenStreetMapLayer

All Implemented Interfaces:
RemoteResource, LayerContent, Loadable

public final class OpenStreetMapLayer extends WebTiledLayer
A layer that can visualize images from the OpenStreetMap servers.

OpenStreetMap (OSM) is a project to create a free, publicly editable map of the world. This layer displays map content from OpenStreetMap tile servers, using the endpoint pattern https://{subDomain}{level}/{col}/{row}.png, where the subDomain is one of [a,b,c]. To provide a custom endpoint instead, use WebTiledLayer(String).

An OpenStreetMapLayer is a preconfigured WebTiledLayer. Unlike a web tiled layer, it comes with predefined attribution and does not support identify, query, selection, or time. Performance of OSM layers is similar to web tiled layer performance. Raster tiles are read from the service as needed by the map.

Use of OpenStreetMap's tiles is subject to their tile usage policy. Before using an OpenStreetMap layer in your app, consider that service availability is not guaranteed. Apps with high demand may be denied access at any time. There are many organizations providing OpenStreetMap tiles. Consider using one of these services (or hosting your own) if you anticipate high demand.

Example for working with an OpenStreetMapLayer

 OpenStreetMapLayer openStreetMapLayer = new OpenStreetMapLayer();
 openStreetMapLayer.addDoneLoadingListener(new Runnable() {
   public void run() {
     if (openStreetMapLayer.getLoadStatus() == LoadStatus.LOADED) {
       // work with the layer here
 map.setBasemap(new Basemap(openStreetMapLayer));
The layer is loaded when displayed in a MapView or a SceneView; if using the layer without a MapView or a SceneView, call the Layer.loadAsync() method. Use the layer done loading event to determine when the layer is ready, and check the loaded status before using the layer.
See Also:
  • Constructor Details

    • OpenStreetMapLayer

      public OpenStreetMapLayer()
      Creates an OpenStreetMap layer from the default OpenStreetMap servers.
  • Method Details

    • setAttribution

      public void setAttribution(String attribution)
      Throws UnsupportedOperationException. Attribution text of an OpenStreetMapLayer cannot be changed.
      setAttribution in class WebTiledLayer
      attribution - the attribution text
      UnsupportedOperationException - always throws this exception
    • copy

      public OpenStreetMapLayer copy()
      Creates a deep copy of this OpenStreetMapLayer instance.
      copy in class WebTiledLayer
      a deep copy of this OpenStreetMapLayer instance, which means that copies of all fields of this layer are made including its loading state