public abstract class TileMap<T> extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
TileMap.ViewportTileProcessor<T>
Callback function for viewport tile processing.
|
Modifier | Constructor and Description |
---|---|
protected |
TileMap() |
protected |
TileMap(int bufferColumns,
int bufferRows) |
Modifier and Type | Method and Description |
---|---|
void |
cacheTile(TileKey key)
Buffer a map tile which is not shown in the viewport, given a map tile key.
|
Collection<ViewportTile<T>> |
collectViewportTiles(int widthPixels,
int heightPixels,
GeoPoint mapCenter,
int zoomLevel)
Get all tiles for a specific viewport.
|
static TileOffset |
convertLatLonToTileOffset(GeoPoint point,
int zoomLevel)
Convert a lat/lon coordinate to a map tile with an offset within the tile.
|
static Tuple<Integer,Integer> |
convertLatLonToViewportXY(GeoPoint point,
int width,
int height,
int zoomLevel,
GeoPoint mapCenter)
Given a viewport calculate the (x, y) position of a lat/lon.
|
static GeoPoint |
convertTileOffsetToLatLon(TileOffset tileOffset)
Convert a map tile with zoomlevel and offset to a lat/lon coordinate.
|
static GeoPoint |
convertViewportXYToLatLon(int posX,
int posY,
int width,
int height,
int zoomLevel,
GeoPoint mapCenter)
Convert a (X, Y) position on a screen to a latitude and longitude, given the center of the map and the
zoomLevel.
|
static Tuple<Integer,GeoPoint> |
findZoomLevelAndMapCenter(int width,
int height,
int borderWidth,
Collection<GeoPoint> points)
Given a set of points, a viewport width/height and the border width, return a zoomlevel and map center that will
contain the specific viewport.
|
abstract T |
getTile(TileKey key)
Get a map tile, given a map tile key.
|
boolean |
isCacheEnabled()
Returns if the map supports caching.
|
boolean |
isPreCacheEnabled()
Returns if the map supports pre-caching of additional non-visible tiles.
|
static GeoPoint |
moveLatLonByViewportXY(int deltaX,
int deltaY,
int zoomLevel,
GeoPoint mapCenter)
Calculate a new map center, given a delta in pixels.
|
void |
processViewportTiles(int widthPixels,
int heightPixels,
GeoPoint mapCenter,
int zoomLevel,
TileMap.ViewportTileProcessor<T> processor)
Process all tiles for a specific viewport.
|
void |
setPreCachingHint(boolean preCaching)
Set pre-caching on or off, if possible.
|
protected TileMap()
protected TileMap(int bufferColumns, int bufferRows)
@Nullable public abstract T getTile(@Nonnull TileKey key)
key
- Tile key.public boolean isCacheEnabled()
public void setPreCachingHint(boolean preCaching)
preCaching
- True of pre-caching is enabled.public boolean isPreCacheEnabled()
public void cacheTile(@Nonnull TileKey key)
key
- Tile key.public void processViewportTiles(int widthPixels, int heightPixels, @Nonnull GeoPoint mapCenter, int zoomLevel, @Nonnull TileMap.ViewportTileProcessor<T> processor)
widthPixels
- Width of viewport in pixels.heightPixels
- Height of viewport in pixels.mapCenter
- Center of map, as lat/lon.zoomLevel
- Zoomlevel (from 0..LbsConst.MapConst.MAXIMUM_ZOOM).processor
- Viewport processor.@Nonnull public Collection<ViewportTile<T>> collectViewportTiles(int widthPixels, int heightPixels, @Nonnull GeoPoint mapCenter, int zoomLevel)
widthPixels
- Width of viewport in pixels.heightPixels
- Height of viewport in pixels.mapCenter
- Center of map, as lat/lon.zoomLevel
- Zoomlevel (from 0..LbsConst.MapConst.MAXIMUM_ZOOM).@Nonnull public static TileOffset convertLatLonToTileOffset(@Nonnull GeoPoint point, int zoomLevel)
point
- Coordinate.zoomLevel
- Zoom level.@Nonnull public static GeoPoint convertTileOffsetToLatLon(@Nonnull TileOffset tileOffset)
tileOffset
- Map tile with zoomlevel and offset within tile.@Nonnull public static GeoPoint convertViewportXYToLatLon(int posX, int posY, int width, int height, int zoomLevel, @Nonnull GeoPoint mapCenter)
posX
- Offset in pixels from left.posY
- Offset in pixels from top.width
- Width in pixels.height
- Height in pixels.zoomLevel
- Zoom level.mapCenter
- Latitude and longitude of center of map.@Nullable public static Tuple<Integer,Integer> convertLatLonToViewportXY(@Nonnull GeoPoint point, int width, int height, int zoomLevel, @Nonnull GeoPoint mapCenter)
point
- Lat/lon.width
- Width of viewport.height
- Height of viewport.zoomLevel
- Zoomlevel of viewport.mapCenter
- Latitude and longitude of center of map.@Nonnull public static Tuple<Integer,GeoPoint> findZoomLevelAndMapCenter(int width, int height, int borderWidth, @Nonnull Collection<GeoPoint> points)
width
- Width of viewport.height
- Height of viewport.borderWidth
- Border width (in pixels) inside viewport to keep points clear from.points
- Points to fit in viewport (but not in border).@Nonnull public static GeoPoint moveLatLonByViewportXY(int deltaX, int deltaY, int zoomLevel, @Nonnull GeoPoint mapCenter)
deltaX
- Delta in pixels to left.deltaY
- Delta in pixels to bottom.zoomLevel
- Zoom level.mapCenter
- Latitude and longitude of center of map.Copyright © 2018 TomTom International BV. All rights reserved.