Interface MapSurface
public interface MapSurface
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.
-
Method Summary
Modifier and TypeMethodDescriptionvoidRegisters a camera-change listener.Adds a circle and returns it for chaining.voidRegisters a long-press listener.addMarker(MarkerOptions options) Adds a marker described byoptionsand returns its live handle.addPolygon(Polygon polygon) Adds a polygon and returns it for chaining.addPolyline(Polyline polyline) Adds a polyline and returns it for chaining.voidRegisters a tap listener.This surface as a Codename OneComponentfor layout purposes.voidRemoves every marker, polyline, polygon and circle.voidMoves and zooms the camera soboundsfits within the viewport, inset bypaddingPixelson every edge.The current camera position (target, zoom, bearing, tilt).The geographic coordinate at the center of the viewport.doubleThe largest zoom level the backend permits.doubleThe smallest zoom level the backend permits.The geographic bounds currently visible, ornullbefore layout.doublegetZoom()The current zoom level.booleanTrue when a native provider currently backs this surface; false for a pure-vector map or aNativeMapthat fell back to the vector engine.latLngToScreen(LatLng coord) Converts a geographic coordinate to a pixel relative to this component.voidmoveCamera(LatLng target, double zoom) Convenience to recenter attargetand setzoomin one call.voidUnregisters a camera-change listener.voidremoveCircle(Circle circle) Removes a previously added circle.voidUnregisters a long-press listener.voidremoveMarker(Marker marker) Removes a previously added marker.voidremovePolygon(Polygon polygon) Removes a previously added polygon.voidremovePolyline(Polyline polyline) Removes a previously added polyline.voidUnregisters a tap listener.screenToLatLng(int x, int y) Converts a pixel relative to this component to a geographic coordinate.voidsetCameraPosition(CameraPosition position) Moves the camera toposition, animating where the backend supports it.voidRecenters the viewport atcenter, keeping the current zoom.voidsetZoom(double zoom) Sets the zoom level, keeping the current center.
-
Method Details
-
getCameraPosition
CameraPosition getCameraPosition()The current camera position (target, zoom, bearing, tilt). -
setCameraPosition
Moves the camera toposition, animating where the backend supports it. -
moveCamera
Convenience to recenter attargetand setzoomin one call. -
getZoom
double getZoom()The current zoom level. -
setZoom
void setZoom(double zoom) Sets the zoom level, keeping the current center. -
getMinZoom
double getMinZoom()The smallest zoom level the backend permits. -
getMaxZoom
double getMaxZoom()The largest zoom level the backend permits. -
getCenter
LatLng getCenter()The geographic coordinate at the center of the viewport. -
setCenter
Recenters the viewport atcenter, keeping the current zoom. -
getVisibleRegion
MapBounds getVisibleRegion()The geographic bounds currently visible, ornullbefore layout. (NamedgetVisibleRegionto avoid clashing withComponent.getVisibleBounds(), which returns a pixel rectangle.) -
fitBounds
Moves and zooms the camera soboundsfits within the viewport, inset bypaddingPixelson every edge. -
addMarker
Adds a marker described byoptionsand returns its live handle. -
removeMarker
Removes a previously added marker. -
addPolyline
-
removePolyline
Removes a previously added polyline. -
addPolygon
-
removePolygon
Removes a previously added polygon. -
addCircle
-
removeCircle
Removes a previously added circle. -
clearMapObjects
void clearMapObjects()Removes every marker, polyline, polygon and circle. -
latLngToScreen
-
screenToLatLng
Converts a pixel relative to this component to a geographic coordinate. -
addTapListener
Registers a tap listener. -
removeTapListener
Unregisters a tap listener. -
addLongPressListener
Registers a long-press listener. -
removeLongPressListener
Unregisters a long-press listener. -
addCameraChangeListener
Registers a camera-change listener. -
removeCameraChangeListener
Unregisters a camera-change listener. -
isNativeMap
boolean isNativeMap()True when a native provider currently backs this surface; false for a pure-vector map or aNativeMapthat fell back to the vector engine. -
asComponent
-