kopia lustrzana https://github.com/robhawkes/vizicities
142 wiersze
3.0 KiB
JavaScript
142 wiersze
3.0 KiB
JavaScript
var world = new VIZI.World({
|
|
viewport: document.querySelector("#vizicities-viewport")
|
|
});
|
|
|
|
var controls = new VIZI.ControlsMap(world.camera, {
|
|
viewport: world.options.viewport
|
|
});
|
|
|
|
var gpxConfig = {
|
|
input: {
|
|
type: "BlueprintInputGPX",
|
|
options: {
|
|
path: "./data/sample.gpx"
|
|
}
|
|
},
|
|
output: {
|
|
type: "BlueprintOutputDebugLines",
|
|
options: {}
|
|
},
|
|
triggers: [{
|
|
triggerObject: "output",
|
|
triggerName: "initialised",
|
|
triggerArguments: [],
|
|
actionObject: "input",
|
|
actionName: "requestData",
|
|
actionArguments: [],
|
|
actionOutput: {}
|
|
}, {
|
|
triggerObject: "input",
|
|
triggerName: "dataReceived",
|
|
triggerArguments: ["gpx"],
|
|
actionObject: "output",
|
|
actionName: "outputLines",
|
|
actionArguments: ["data"],
|
|
actionOutput: {
|
|
data: {
|
|
process: "map",
|
|
itemsObject: "gpx",
|
|
itemsProperties: "trk.trkseg.trkpt",
|
|
transformation: {
|
|
coordinates: ["@lon", "@lat"],
|
|
height: "ele"
|
|
}
|
|
}
|
|
}
|
|
}]
|
|
};
|
|
|
|
var switchboardGPX = new VIZI.BlueprintSwitchboard(gpxConfig);
|
|
switchboardGPX.addToWorld(world);
|
|
|
|
var mapConfig = {
|
|
input: {
|
|
type: "BlueprintInputMapTiles",
|
|
options: {
|
|
tilePath: "http://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}@2x.png"
|
|
}
|
|
},
|
|
output: {
|
|
type: "BlueprintOutputImageTiles",
|
|
options: {
|
|
grids: [{
|
|
zoom: 19,
|
|
tilesPerDirection: 3,
|
|
cullZoom: 17
|
|
}, {
|
|
zoom: 18,
|
|
tilesPerDirection: 3,
|
|
cullZoom: 16
|
|
}, {
|
|
zoom: 17,
|
|
tilesPerDirection: 3,
|
|
cullZoom: 15
|
|
}, {
|
|
zoom: 16,
|
|
tilesPerDirection: 3,
|
|
cullZoom: 14
|
|
}, {
|
|
zoom: 15,
|
|
tilesPerDirection: 3,
|
|
cullZoom: 13
|
|
}, {
|
|
zoom: 14,
|
|
tilesPerDirection: 3,
|
|
cullZoom: 12
|
|
}, {
|
|
zoom: 13,
|
|
tilesPerDirection: 5,
|
|
cullZoom: 11
|
|
}]
|
|
}
|
|
},
|
|
triggers: [{
|
|
triggerObject: "output",
|
|
triggerName: "initialised",
|
|
triggerArguments: ["tiles"],
|
|
actionObject: "input",
|
|
actionName: "requestTiles",
|
|
actionArguments: ["tiles"],
|
|
actionOutput: {
|
|
tiles: "tiles" // actionArg: triggerArg
|
|
}
|
|
}, {
|
|
triggerObject: "output",
|
|
triggerName: "gridUpdated",
|
|
triggerArguments: ["tiles"],
|
|
actionObject: "input",
|
|
actionName: "requestTiles",
|
|
actionArguments: ["tiles"],
|
|
actionOutput: {
|
|
tiles: "tiles" // actionArg: triggerArg
|
|
}
|
|
}, {
|
|
triggerObject: "input",
|
|
triggerName: "tileReceived",
|
|
triggerArguments: ["image", "tile"],
|
|
actionObject: "output",
|
|
actionName: "outputImageTile",
|
|
actionArguments: ["image", "tile"],
|
|
actionOutput: {
|
|
image: "image", // actionArg: triggerArg
|
|
tile: "tile"
|
|
}
|
|
}]
|
|
};
|
|
|
|
var switchboardMap = new VIZI.BlueprintSwitchboard(mapConfig);
|
|
switchboardMap.addToWorld(world);
|
|
|
|
var clock = new VIZI.Clock();
|
|
|
|
var update = function() {
|
|
var delta = clock.getDelta();
|
|
|
|
world.onTick(delta);
|
|
world.render();
|
|
|
|
window.requestAnimationFrame(update);
|
|
};
|
|
|
|
update();
|