Class MapProvider

java.lang.Object
com.codename1.maps.providers.MapProvider
Direct Known Subclasses:
TiledProvider

public abstract class MapProvider extends java.lang.Object
This is a generic map provider.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a new MapProvider
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract String
    The provider attribution.
    abstract BoundingBox
    bboxFor(Coord position, int zoomLevel)
    Returns the bounding box of a position ina given zoom level
    int
    Returns the maximum zoom of a specific Tile.
    abstract int
    Maximal zoom level.
    int
    Minimal zoom level user is able to see.
    Gets the Provider projection
    abstract Coord
    scale(int zoomLevel)
    Scale is the distance in map units between each pixel in tile at given zoom level.
    abstract Tile
    Gets a tile for the given bounding box
    Gets the tile size
    void
    Request map to provide tiles of specific sizes.
    translate(Coord position, int zoomLevel, int pixelsX, int pixelsY)
    Translates position by [pixelsX, pixelsY] at zoomLevel acordingly to maps scale.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MapProvider

      protected MapProvider(Projection p, Dimension tileSize)

      Creates a new MapProvider

      Parameters
      • p: the projection system

      • tileSize: the tile size

  • Method Details

    • tileSize

      public void tileSize(Dimension size)

      Request map to provide tiles of specific sizes. May not be supported by map provider. By default it does nothing;

      Parameters
      • size: requested tile size
    • bboxFor

      public abstract BoundingBox bboxFor(Coord position, int zoomLevel)

      Returns the bounding box of a position ina given zoom level

      Parameters
      • position: on the map

      • zoomLevel: the zoom level

      Returns

      a bounding box

    • tileFor

      public abstract Tile tileFor(BoundingBox bbox)

      Gets a tile for the given bounding box

      Parameters
      • bbox: a bounding box
      Returns

      a Tile for the given bounding box

    • maxZoomLevel

      public abstract int maxZoomLevel()
      Maximal zoom level. Zoom levels are counted from zero to maxZoomLevel(). 0 is farest view, where the scale is greatest.
    • minZoomLevel

      public int minZoomLevel()
      Minimal zoom level user is able to see.
    • scale

      public abstract Coord scale(int zoomLevel)

      Scale is the distance in map units between each pixel in tile at given zoom level.

      Returns

      Scale at given zoom level.

    • translate

      public Coord translate(Coord position, int zoomLevel, int pixelsX, int pixelsY)

      Translates position by [pixelsX, pixelsY] at zoomLevel acordingly to maps scale.

      Parameters
      • position: in map projection

      • zoomLevel

      • pixelsX

      • pixelsY

      Returns

      translated position.

    • projection

      public Projection projection()

      Gets the Provider projection

      Returns

      the Provider projection

    • tileSize

      public Dimension tileSize()

      Gets the tile size

      Returns

      the tile size

    • attribution

      public abstract String attribution()

      The provider attribution.

      Returns

      a String of the provider attribution

    • maxZoomFor

      public int maxZoomFor(Tile tile)

      Returns the maximum zoom of a specific Tile.

      Parameters
      • tile: tile to check the max zoom
      Returns

      the max zoom of the tile