I'm trying to find out which is the currently centered tile in OpenLayers 3.
I can get the current position as latitude/longitude with map.getView().getCenter()
, and the zoom level as map.getView().getZoom()
.
Am I supposed to convert this to map tiles manually, or does OpenLayers 3 provide a functionality to easily calculate the correct tile x/y indices (the one in which the center lat/lon is located), or am I supposed to calculate this by myself?
您可以将中心位置转换为
center = ol.proj.transform(center, 'EPSG:900913', 'EPSG:4326');
Given a ol3 tile source, you can get the TileGrid
by source.getTileGrid()
.
Then use the getTileCoordForCoordAndResolution
method, to get the tile coordinates from a given map coordinate and resolution.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.