Class OpenStreetMapLayer

  • All Implemented Interfaces:
    RemoteResource, LayerContent, Loadable

    public final class OpenStreetMapLayer
    extends WebTiledLayer
    A layer that requests images from 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}.tile.openstreetmap.org/{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));
     
     mapView.setMap(map);
     
    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.
    Since:
    100.1.0
    See Also:
    Layer, WebTiledLayer
    • Constructor Detail

      • OpenStreetMapLayer

        public OpenStreetMapLayer()
        Creates an instance of OpenStreetMapLayer.
        Since:
        100.1.0
    • Method Detail

      • setAttribution

        public void setAttribution​(java.lang.String attribution)
        Throws UnsupportedOperationException. Attribution text of an OpenStreetMapLayer cannot be changed.
        Overrides:
        setAttribution in class WebTiledLayer
        Parameters:
        attribution - the attribution text
        Throws:
        java.lang.UnsupportedOperationException - always throws this exception
        Since:
        100.1.0
      • copy

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