는 지금까지 내가 아는 한, 당신은 당신이 다음에 그것들을 열거 할 수 getPixelBounds()
을 통과해야 코드 : xTile와 yTile 당신이
// get bounds, zoom and tileSize
var bounds = map.getPixelBounds();
var zoom = map.getZoom();
var tileSize = 256;
// get NorthWest and SouthEast points
var nwTilePoint = new L.Point(Math.floor(bounds.min.x/tileSize),
Math.floor(bounds.min.y/tileSize));
var seTilePoint = new L.Point(Math.floor(bounds.max.x/tileSize),
Math.floor(bounds.max.y/tileSize));
// get max number of tiles in this zoom level
var max = map.options.crs.scale(zoom)/tileSize;
// enumerate visible tiles
for (var x = nwTilePoint.x; x <= seTilePoint.x; x++) {
for (var y = nwTilePoint.y; y <= seTilePoint.y; y++) {
var xTile = (x + max) % max;
var yTile = (y + max) % max;
console.log('tile ' + xTile + ' ' + yTile);
}
}
큰 코드를 찾고있는 무엇인가! 고맙습니다! 하나의 코너 케이스가 있습니다. Math.abs (x % max)와 Math.abs (y % max)로 설정하십시오. 때때로 부정적인 타일 코디를 사용하게됩니다. – warmspringwinds
사실, x와 y는 메르카토르 투영법에서 항상 양수입니다. http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#X_and_Y – YaFred
네가 맞다. 그러나지도를 왼쪽으로 스크롤하면 getPixelBounds()가 음수 x를 반환한다. 지도가 반복되기 시작하면 – warmspringwinds