Class VectorMapEngine
java.lang.Object
com.codename1.maps.vector.VectorMapEngine
The pure-Codename One map renderer behind MapView (and
the NativeMap fallback).
It maintains the camera (center + fractional zoom), pulls tiles from a
TileSource, rasterizes vector tiles once into 256px buffers (or decodes
raster tiles), caches them in an LRU TileCache, and on each paint blits
the visible buffers scaled to the fractional zoom and places labels with
the LabelEngine. All drawing uses the framework Graphics API -- there
is no native peer.
-
Constructor Summary
ConstructorsConstructorDescriptionVectorMapEngine(TileSource source, MapStyle style) Creates an engine oversource, styled bystyle. -
Method Summary
Modifier and TypeMethodDescriptionvoidDrops all cached tiles (e.g. on low memory).voidMoves the camera soboundsfits the viewport inset bypadding.The geographic coordinate at the center of the viewport.doubleThe largest zoom level the tile source serves.doubleThe smallest zoom level the tile source serves.The active tile source.getStyle()The active style.The geographic bounds currently visible, or null before layout.doublegetZoom()The current fractional zoom level.latLngToScreen(LatLng coord) Geographic to component-relative pixel.voidPaints the basemap and labels intog, offset byoriginX,originY.voidpanPixels(double dx, double dy) Pans the camera by a pixel delta (used for drag gestures).screenToLatLng(int x, int y) Component-relative pixel to geographic.voidRecenters the camera atcenter, keeping the current zoom.voidSets the callback invoked (on the EDT) whenever a tile finishes loading and the map needs to repaint.voidsetSource(TileSource source) Replaces the tile source, clearing cached tiles.voidReplaces the style, clearing rendered tiles so they redraw.voidsetViewport(int width, int height) Sets the pixel size of the viewport (called by the host component on layout before painting and coordinate conversion).voidsetZoom(double zoom) Sets the zoom level, clamped to the source's min/max.voidzoomAround(double newZoom, int sx, int sy) Zooms tonewZoomwhile keeping the geographic point currently under the component pixelsx,syfixed (used for pinch and double-tap).
-
Constructor Details
-
VectorMapEngine
Creates an engine oversource, styled bystyle.
-
-
Method Details
-
setRepaintCallback
Sets the callback invoked (on the EDT) whenever a tile finishes loading and the map needs to repaint. -
setSource
Replaces the tile source, clearing cached tiles. -
getSource
The active tile source. -
setStyle
Replaces the style, clearing rendered tiles so they redraw. -
getStyle
The active style. -
setCenter
Recenters the camera atcenter, keeping the current zoom. -
getCenter
The geographic coordinate at the center of the viewport. -
setZoom
public void setZoom(double zoom) Sets the zoom level, clamped to the source's min/max. -
getZoom
public double getZoom()The current fractional zoom level. -
getMinZoom
public double getMinZoom()The smallest zoom level the tile source serves. -
getMaxZoom
public double getMaxZoom()The largest zoom level the tile source serves. -
setViewport
public void setViewport(int width, int height) Sets the pixel size of the viewport (called by the host component on layout before painting and coordinate conversion). -
latLngToScreen
-
panPixels
public void panPixels(double dx, double dy) Pans the camera by a pixel delta (used for drag gestures). A positivedxmoves the map content to the right. -
zoomAround
public void zoomAround(double newZoom, int sx, int sy) Zooms tonewZoomwhile keeping the geographic point currently under the component pixelsx,syfixed (used for pinch and double-tap). -
screenToLatLng
Component-relative pixel to geographic. -
getVisibleBounds
The geographic bounds currently visible, or null before layout. -
fitBounds
Moves the camera soboundsfits the viewport inset bypadding. -
paint
Paints the basemap and labels intog, offset byoriginX,originY. The caller is responsible for clipping to the component bounds and for drawing overlays (markers/shapes) afterwards. -
clearCache
public void clearCache()Drops all cached tiles (e.g. on low memory).
-