# Interface MapProvider

All Known Implementing Classes:
  `WebMapProvider`

public interface MapProvider

The service-provider interface a native map backend implements so the core `NativeMap` component can drive it without knowing which provider (Apple MapKit, Google Maps, Bing, Huawei, ...) is in use.

This is a plain interface, deliberately not a `com.codename1.system.NativeInterface`: core neither ships nor references any concrete implementation. When the developer selects a provider with the `maps.provider` build hint, the build pushes a provider implementation (carrying the platform-native methods) into the `com.codename1.maps` package of the app and weaves in a call to `MapProviderRegistry.register(MapProvider)`. Absent that injection the registry stays empty and `NativeMap` falls back to the pure-vector `MapView`.

Every method is keyed by a `mapId` so a single provider implementation can serve multiple `NativeMap` instances. Coordinate conversion uses a stateful "calculate then read" idiom (`calcScreenPosition(int, double, double)` then `getScreenX(int)` / `getScreenY(int)`) to avoid returning multiple values across the native boundary. Native code reports user interaction back through the static callbacks on `NativeMap` (`fireTap`, `fireLongPress`, `fireMarkerClick`, `fireCameraChange`, `fireMapReady`).

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `MAP_TYPE_HYBRID`
  Map type: hybrid imagery with labels.
  `static final int`
  `MAP_TYPE_SATELLITE`
  Map type: satellite imagery.
  `static final int`
  `MAP_TYPE_STANDARD`
  Map type: standard street map.
  `static final int`
  `MAP_TYPE_TERRAIN`
  Map type: terrain relief.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long`
  `addCircle(int mapId, double lat, double lon, double radiusMeters, int fillColor, int strokeColor, int strokeWidth)`
  Adds a geodesic circle and returns its element key.
  `long`
  `addMarker(int mapId, byte[] icon, double lat, double lon, String title, String snippet, float anchorU, float anchorV)`
  Adds a marker.
  `void`
  `addToPath(int mapId, long pathId, double lat, double lon)`
  `long`
  `beginPath(int mapId)`
  Starts accumulating a path; feed it with `addToPath(int, long, double, double)`.
  `void`
  `calcLatLongPosition(int mapId, int x, int y)`
  `void`
  `calcScreenPosition(int mapId, double lat, double lon)`
  `Component`
  `createPeer(NativeMap host, int mapId)`
  Creates the view for the map identified by `mapId`.
  `void`
  `deinitialize(int mapId)`
  Releases native resources for `mapId` when the map is no longer used.
  `long`
  `finishPolygon(int mapId, long pathId, int fillColor, int strokeColor, int strokeWidth)`
  Finishes the path as a filled polygon and returns its element key.
  `long`
  `finishPolyline(int mapId, long pathId, int strokeColor, int strokeWidth)`
  Finishes the path as a stroked polyline and returns its element key.
  `String`
  `getId()`
  A stable identifier for this provider, e.g.
  `double`
  `getLatitude(int mapId)`
  `double`
  `getLongitude(int mapId)`
  `float`
  `getMaxZoom(int mapId)`
  `float`
  `getMinZoom(int mapId)`
  `double`
  `getScreenLat(int mapId)`
  `double`
  `getScreenLon(int mapId)`
  `int`
  `getScreenX(int mapId)`
  `int`
  `getScreenY(int mapId)`
  `float`
  `getZoom(int mapId)`
  `boolean`
  `isAvailable()`
  Whether this provider can render on the current device right now (e.g. Google checks that Play Services is present).
  `void`
  `removeAllElements(int mapId)`
  `void`
  `removeElement(int mapId, long elementId)`
  `void`
  `setCamera(int mapId, double lat, double lon, float zoom, float bearing, float tilt)`
  Moves the camera.
  `void`
  `setMapType(int mapId, int type)`
  `void`
  `setRotateGestureEnabled(int mapId, boolean enabled)`
  `void`
  `setShowMyLocation(int mapId, boolean show)`

- ## Field Details

  - ### MAP_TYPE_STANDARD

    static final int MAP_TYPE_STANDARD
    Map type: standard street map.
    See Also:
      - Constant Field Values

  - ### MAP_TYPE_SATELLITE

    static final int MAP_TYPE_SATELLITE
    Map type: satellite imagery.
    See Also:
      - Constant Field Values

  - ### MAP_TYPE_HYBRID

    static final int MAP_TYPE_HYBRID
    Map type: hybrid imagery with labels.
    See Also:
      - Constant Field Values

  - ### MAP_TYPE_TERRAIN

    static final int MAP_TYPE_TERRAIN
    Map type: terrain relief.
    See Also:
      - Constant Field Values

- ## Method Details

  - ### getId

    String getId()
    A stable identifier for this provider, e.g. `"apple"` or `"google"`.

  - ### isAvailable

    boolean isAvailable()
    Whether this provider can render on the current device right now (e.g. Google checks that Play Services is present). When this returns false `NativeMap` falls back to the vector engine.

  - ### createPeer

    Component createPeer(NativeMap host, int mapId)
    Creates the view for the map identified by `mapId`. Native providers return a `PeerComponent` wrapping the native map view; a web-SDK provider returns a `BrowserComponent`. Either way it is a `Component` the `NativeMap` adds to its layout. Returning `null` triggers the vector fallback.

  - ### deinitialize

    void deinitialize(int mapId)
    Releases native resources for `mapId` when the map is no longer used.

  - ### setCamera

    void setCamera(int mapId, double lat, double lon, float zoom, float bearing, float tilt)
    Moves the camera. `bearing` and `tilt` are in degrees; providers that do not support them ignore those arguments.

  - ### getLatitude

    double getLatitude(int mapId)

  - ### getLongitude

    double getLongitude(int mapId)

  - ### getZoom

    float getZoom(int mapId)

  - ### getMaxZoom

    float getMaxZoom(int mapId)

  - ### getMinZoom

    float getMinZoom(int mapId)

  - ### addMarker

    long addMarker(int mapId, byte[] icon, double lat, double lon, String title, String snippet, float anchorU, float anchorV)
    Adds a marker. `icon` is PNG bytes (or `null` for the default pin); returns an opaque element key. `anchorU`/`anchorV` are normalized.

  - ### beginPath

    long beginPath(int mapId)
    Starts accumulating a path; feed it with `addToPath(int, long, double, double)`.

  - ### addToPath

    void addToPath(int mapId, long pathId, double lat, double lon)

  - ### finishPolyline

    long finishPolyline(int mapId, long pathId, int strokeColor, int strokeWidth)
    Finishes the path as a stroked polyline and returns its element key.

  - ### finishPolygon

    long finishPolygon(int mapId, long pathId, int fillColor, int strokeColor, int strokeWidth)
    Finishes the path as a filled polygon and returns its element key.

  - ### addCircle

    long addCircle(int mapId, double lat, double lon, double radiusMeters, int fillColor, int strokeColor, int strokeWidth)
    Adds a geodesic circle and returns its element key.

  - ### removeElement

    void removeElement(int mapId, long elementId)

  - ### removeAllElements

    void removeAllElements(int mapId)

  - ### calcScreenPosition

    void calcScreenPosition(int mapId, double lat, double lon)

  - ### getScreenX

    int getScreenX(int mapId)

  - ### getScreenY

    int getScreenY(int mapId)

  - ### calcLatLongPosition

    void calcLatLongPosition(int mapId, int x, int y)

  - ### getScreenLat

    double getScreenLat(int mapId)

  - ### getScreenLon

    double getScreenLon(int mapId)

  - ### setShowMyLocation

    void setShowMyLocation(int mapId, boolean show)

  - ### setRotateGestureEnabled

    void setRotateGestureEnabled(int mapId, boolean enabled)

  - ### setMapType

    void setMapType(int mapId, int type)