Viewport Calculator
Utility for calculating which map tiles are visible in the viewport.
Determines tile coordinates based on map center, zoom level, and view dimensions. Includes buffering for smooth panning experience.
The world repeats horizontally, so tile X may be below 0 or above 2^zoom - 1 for the copies of the world left and right of the main one. Such a tile is placed by its X, and TileCoordinate.wrapped gives the tile to load for it.
Functions
Link copied to clipboard
fun getVisibleTiles(center: LatLng, zoom: Int, viewWidth: Int, viewHeight: Int, panOffsetX: Float = 0.0f, panOffsetY: Float = 0.0f): List<TileCoordinate>
Calculates which tiles are visible in the current viewport.
fun getVisibleTiles(center: LatLng, zoom: Float, viewWidth: Int, viewHeight: Int, panOffsetX: Float = 0.0f, panOffsetY: Float = 0.0f, tileSize: Double = ProjectionUtils.TILE_SIZE): List<TileCoordinate>
Calculates which tiles are visible at a fractional zoom level.