public interface MapSurface

Known subtypesMapView, NativeMap

The provider-agnostic map API shared by the pure-vector MapView and the native-peer NativeMap.

Application code should program against MapSurface so it does not need to know whether the map is drawn by the built-in vector engine or by a native provider (Apple MapKit, Google Maps, …). The two concrete components differ only in how they render; their behavior through this interface is identical, and a NativeMap with no native provider wired in transparently delegates to an embedded MapView.

Named MapSurface rather than Map to avoid clashing with java.util.Map.

Methods

public abstract CameraPosition getCameraPosition()The current camera position (target, zoom, bearing, tilt).
public abstract void setCameraPosition(CameraPosition position)Moves the camera to position, animating where the backend supports it.
public abstract void moveCamera(LatLng target, double zoom)Convenience to recenter at target and set zoom in one call.
public abstract double getZoom()The current zoom level.
public abstract void setZoom(double zoom)Sets the zoom level, keeping the current center.
public abstract double getMinZoom()The smallest zoom level the backend permits.
public abstract double getMaxZoom()The largest zoom level the backend permits.
public abstract LatLng getCenter()The geographic coordinate at the center of the viewport.
public abstract void setCenter(LatLng center)Recenters the viewport at center, keeping the current zoom.
public abstract MapBounds getVisibleRegion()The geographic bounds currently visible, or null before layout.
public abstract void fitBounds(MapBounds bounds, int paddingPixels)Moves and zooms the camera so bounds fits within the viewport, inset by paddingPixels on every edge.
public abstract Marker addMarker(MarkerOptions options)Adds a marker described by options and returns its live handle.
public abstract void removeMarker(Marker marker)Removes a previously added marker.
public abstract Polyline addPolyline(Polyline polyline)Adds a polyline and returns it for chaining.
public abstract void removePolyline(Polyline polyline)Removes a previously added polyline.
public abstract Polygon addPolygon(Polygon polygon)Adds a polygon and returns it for chaining.
public abstract void removePolygon(Polygon polygon)Removes a previously added polygon.
public abstract Circle addCircle(Circle circle)Adds a circle and returns it for chaining.
public abstract void removeCircle(Circle circle)Removes a previously added circle.
public abstract void clearMapObjects()Removes every marker, polyline, polygon and circle.
public abstract Point latLngToScreen(LatLng coord)Converts a geographic coordinate to a pixel relative to this component.
public abstract LatLng screenToLatLng(int x, int y)Converts a pixel relative to this component to a geographic coordinate.
public abstract void addTapListener(MapTapListener l)Registers a tap listener.
public abstract void removeTapListener(MapTapListener l)Unregisters a tap listener.
public abstract void addLongPressListener(MapTapListener l)Registers a long-press listener.
public abstract void removeLongPressListener(MapTapListener l)Unregisters a long-press listener.
public abstract void addCameraChangeListener(CameraChangeListener l)Registers a camera-change listener.
public abstract void removeCameraChangeListener(CameraChangeListener l)Unregisters a camera-change listener.
public abstract boolean isNativeMap()True when a native provider currently backs this surface; false for a pure-vector map or a NativeMap that fell back to the vector engine.
public abstract boolean isLoadingTiles()Whether the vector engine still has tiles in flight for the current view.
public abstract Component asComponent()This surface as a Codename One Component for layout purposes.

Method details

getCameraPosition

public abstract CameraPosition getCameraPosition()
The current camera position (target, zoom, bearing, tilt).

setCameraPosition

public abstract void setCameraPosition(CameraPosition position)
Moves the camera to position, animating where the backend supports it.

moveCamera

public abstract void moveCamera(LatLng target, double zoom)
Convenience to recenter at target and set zoom in one call.

getZoom

public abstract double getZoom()
The current zoom level.

setZoom

public abstract void setZoom(double zoom)
Sets the zoom level, keeping the current center.

getMinZoom

public abstract double getMinZoom()
The smallest zoom level the backend permits.

getMaxZoom

public abstract double getMaxZoom()
The largest zoom level the backend permits.

getCenter

public abstract LatLng getCenter()
The geographic coordinate at the center of the viewport.

setCenter

public abstract void setCenter(LatLng center)
Recenters the viewport at center, keeping the current zoom.

getVisibleRegion

public abstract MapBounds getVisibleRegion()
The geographic bounds currently visible, or null before layout. (Named getVisibleRegion to avoid clashing with Component.getVisibleBounds(), which returns a pixel rectangle.)

fitBounds

public abstract void fitBounds(MapBounds bounds, int paddingPixels)
Moves and zooms the camera so bounds fits within the viewport, inset by paddingPixels on every edge.

addMarker

public abstract Marker addMarker(MarkerOptions options)
Adds a marker described by options and returns its live handle.

removeMarker

public abstract void removeMarker(Marker marker)
Removes a previously added marker.

addPolyline

public abstract Polyline addPolyline(Polyline polyline)
Adds a polyline and returns it for chaining.

removePolyline

public abstract void removePolyline(Polyline polyline)
Removes a previously added polyline.

addPolygon

public abstract Polygon addPolygon(Polygon polygon)
Adds a polygon and returns it for chaining.

removePolygon

public abstract void removePolygon(Polygon polygon)
Removes a previously added polygon.

addCircle

public abstract Circle addCircle(Circle circle)
Adds a circle and returns it for chaining.

removeCircle

public abstract void removeCircle(Circle circle)
Removes a previously added circle.

clearMapObjects

public abstract void clearMapObjects()
Removes every marker, polyline, polygon and circle.

latLngToScreen

public abstract Point latLngToScreen(LatLng coord)
Converts a geographic coordinate to a pixel relative to this component.

screenToLatLng

public abstract LatLng screenToLatLng(int x, int y)
Converts a pixel relative to this component to a geographic coordinate.

addTapListener

public abstract void addTapListener(MapTapListener l)
Registers a tap listener.

removeTapListener

public abstract void removeTapListener(MapTapListener l)
Unregisters a tap listener.

addLongPressListener

public abstract void addLongPressListener(MapTapListener l)
Registers a long-press listener.

removeLongPressListener

public abstract void removeLongPressListener(MapTapListener l)
Unregisters a long-press listener.

addCameraChangeListener

public abstract void addCameraChangeListener(CameraChangeListener l)
Registers a camera-change listener.

removeCameraChangeListener

public abstract void removeCameraChangeListener(CameraChangeListener l)
Unregisters a camera-change listener.

isNativeMap

public abstract boolean isNativeMap()
True when a native provider currently backs this surface; false for a pure-vector map or a NativeMap that fell back to the vector engine.

isLoadingTiles

public abstract boolean isLoadingTiles()
Whether the vector engine still has tiles in flight for the current view. Useful to defer a screenshot (or hide a spinner) until the basemap has finished loading. Always false for a native-provider-backed surface, which loads its own tiles outside the engine’s knowledge.

asComponent

public abstract Component asComponent()
This surface as a Codename One Component for layout purposes.