kopia lustrzana https://github.com/robhawkes/vizicities
Added event to listen for tile list updates on a layer
rodzic
c7793b21f6
commit
c296afef17
|
@ -0,0 +1,18 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title>Tile Events ViziCities Example</title>
|
||||
<link rel="stylesheet" href="main.css">
|
||||
<link rel="stylesheet" href="../../dist/vizicities.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="world"></div>
|
||||
|
||||
<script src="../vendor/three.min.js"></script>
|
||||
<script src="../vendor/TweenMax.min.js"></script>
|
||||
<script src="../../dist/vizicities.min.js"></script>
|
||||
|
||||
<script src="main.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,4 @@
|
|||
* { margin: 0; padding: 0; }
|
||||
html, body { height: 100%; overflow: hidden;}
|
||||
|
||||
#world { height: 100%; }
|
|
@ -0,0 +1,25 @@
|
|||
// Manhattan
|
||||
var coords = [40.739940, -73.988801];
|
||||
|
||||
var world = VIZI.world('world', {
|
||||
skybox: false,
|
||||
postProcessing: false
|
||||
}).setView(coords);
|
||||
|
||||
// Add controls
|
||||
VIZI.Controls.orbit().addTo(world);
|
||||
|
||||
// CartoDB basemap
|
||||
var imageTiles = VIZI.imageTileLayer('http://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}.png', {
|
||||
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="http://cartodb.com/attributions">CartoDB</a>'
|
||||
});
|
||||
|
||||
imageTiles.addTo(world).then(() => {
|
||||
console.log('Added image tile layer to world');
|
||||
});
|
||||
|
||||
// Will be emitted every time the image layer updates the tile list
|
||||
// All tiles in view are sent with each update
|
||||
imageTiles.on('tilesList', (tiles) => {
|
||||
console.log(tiles);
|
||||
});
|
|
@ -126,6 +126,9 @@ class TileLayer extends Layer {
|
|||
this._tilesPicking.add(tile.getPickingMesh());
|
||||
}
|
||||
});
|
||||
|
||||
// Emit event notifying of new tiles
|
||||
this.emit('tilesList', this._tileList.map((tile) => tile._tile));
|
||||
}
|
||||
|
||||
// Works out tiles in the view frustum and stores them in an array
|
||||
|
|
Ładowanie…
Reference in New Issue