# Class MapProvider

java.lang.Object
com.codename1.maps.providers.MapProvider

Direct Known Subclasses:
  `TiledProvider`

public abstract class MapProvider extends Object
This is a generic map provider.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `MapProvider(Projection p, Dimension tileSize)`
  Creates a new MapProvider

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract String`
  `attribution()`
  The provider attribution.
  `abstract BoundingBox`
  `bboxFor(Coord position, int zoomLevel)`
  Returns the bounding box of a position ina given zoom level
  `int`
  `maxZoomFor(Tile tile)`
  Returns the maximum zoom of a specific Tile.
  `abstract int`
  `maxZoomLevel()`
  Maximal zoom level.
  `int`
  `minZoomLevel()`
  Minimal zoom level user is able to see.
  `Projection`
  `projection()`
  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`
  `tileFor(BoundingBox bbox)`
  Gets a tile for the given bounding box
  `Dimension`
  `tileSize()`
  Gets the tile size
  `void`
  `tileSize(Dimension size)`
  Request map to provide tiles of specific sizes.
  `Coord`
  `translate(Coord position, int zoomLevel, int pixelsX, int pixelsY)`
  Translates position by [pixelsX, pixelsY] at zoomLevel acordingly to maps scale.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `final Class`
  `getClass()`
  Returns the runtime class of an object.
  `int`
  `hashCode()`
  Returns a hash code value for the object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `String`
  `toString()`
  Returns a string representation of the object.
  `final void`
  `wait()`
  Causes current thread to wait until another thread invokes the method or the method for this object.
  `final void`
  `wait(long timeout)`
  Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
  `final void`
  `wait(long timeout, int nanos)`
  Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

- ## 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