Class OpenStreetMapLayer

  • All Implemented Interfaces:
    RemoteResource, LayerContent, Loadable

    public final class OpenStreetMapLayer
    extends WebTiledLayer
    Defines a tiled layer created from OpenStreetMap (OSM) tiled service.

    The tiles are fetched from the OpenStreetMap tile server, 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, use WebTiledLayer(String)

    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.getOperationalLayers().add(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
    • Constructor Detail

      • OpenStreetMapLayer

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

      • setAttribution

        public void setAttribution​(String attribution)
        Throws UnsupportedOperationException. Attribution text of an OpenStreetMapLayer cannot be changed.
        Overrides:
        setAttribution in class WebTiledLayer
        Parameters:
        attribution - the attribution text
        Throws:
        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