public interface MapProvider
Known subtypesWebMapProvider
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 then getScreenX /
getScreenY) 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).
Fields
public static final int MAP_TYPE_STANDARD = 0 | Map type: standard street map. |
public static final int MAP_TYPE_SATELLITE = 1 | Map type: satellite imagery. |
public static final int MAP_TYPE_HYBRID = 2 | Map type: hybrid imagery with labels. |
public static final int MAP_TYPE_TERRAIN = 3 | Map type: terrain relief. |
Methods
Field details
MAP_TYPE_STANDARD
public static final int MAP_TYPE_STANDARD = 0MAP_TYPE_SATELLITE
public static final int MAP_TYPE_SATELLITE = 1MAP_TYPE_HYBRID
public static final int MAP_TYPE_HYBRID = 2MAP_TYPE_TERRAIN
public static final int MAP_TYPE_TERRAIN = 3Method details
getId
public abstract String getId()"apple" or "google".isAvailable
public abstract boolean isAvailable()NativeMap falls back to the vector engine.createPeer
public abstract Component createPeer(NativeMap host, int mapId)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
public abstract void deinitialize(int mapId)mapId when the map is no longer used.setCamera
public abstract void setCamera(int mapId, double lat, double lon, float zoom, float bearing, float tilt)bearing and tilt are in degrees; providers that
do not support them ignore those arguments.getLatitude
public abstract double getLatitude(int mapId)getLongitude
public abstract double getLongitude(int mapId)getZoom
public abstract float getZoom(int mapId)getMaxZoom
public abstract float getMaxZoom(int mapId)getMinZoom
public abstract float getMinZoom(int mapId)addMarker
public abstract long addMarker(int mapId, byte[] icon, double lat, double lon, String title, String snippet, float anchorU, float anchorV)icon is PNG bytes (or null for the default pin);
returns an opaque element key. anchorU/anchorV are normalized.beginPath
public abstract long beginPath(int mapId)addToPath.addToPath
public abstract void addToPath(int mapId, long pathId, double lat, double lon)finishPolyline
public abstract long finishPolyline(int mapId, long pathId, int strokeColor, int strokeWidth)finishPolygon
public abstract long finishPolygon(int mapId, long pathId, int fillColor, int strokeColor, int strokeWidth)addCircle
public abstract long addCircle(int mapId, double lat, double lon, double radiusMeters, int fillColor, int strokeColor, int strokeWidth)removeElement
public abstract void removeElement(int mapId, long elementId)removeAllElements
public abstract void removeAllElements(int mapId)calcScreenPosition
public abstract void calcScreenPosition(int mapId, double lat, double lon)getScreenX
public abstract int getScreenX(int mapId)getScreenY
public abstract int getScreenY(int mapId)calcLatLongPosition
public abstract void calcLatLongPosition(int mapId, int x, int y)getScreenLat
public abstract double getScreenLat(int mapId)getScreenLon
public abstract double getScreenLon(int mapId)setShowMyLocation
public abstract void setShowMyLocation(int mapId, boolean show)setRotateGestureEnabled
public abstract void setRotateGestureEnabled(int mapId, boolean enabled)setMapType
public abstract void setMapType(int mapId, int type)