Skip to content

Instantly share code, notes, and snippets.

@veev
Created November 19, 2017 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veev/1a529abdbf2a4c4ed76e94a642ef447d to your computer and use it in GitHub Desktop.
Save veev/1a529abdbf2a4c4ed76e94a642ef447d to your computer and use it in GitHub Desktop.
Mappa with MapboxGL JS - fly to
// Your Mapboxgl API Key
let key = ''; // <your access token here>;
// Create a new Mappa instance using Mapboxgl.
let mappa = new Mappa('Mapboxgl', key);
let myMap;
let canvas;
// Map options
let options = {
lat: 40.782,
lng: -73.967,
zoom: 4,
style: 'mapbox://styles/mapbox/dark-v9'
}
function setup(){
canvas = createCanvas(800, 700);
console.log('creating canvas');
// Create a tile map centered in New York with an initial zoom level of 4.
myMap = mappa.tileMap(options);
// Overlay the tile map to the p5 canvas. This will display the map.
myMap.overlay(canvas);
}
function draw(){
}
function keyReleased() {
console.log(myMap);
myMap.map.flyTo({
center: [
-74.50 + (Math.random() - 0.5) * 10,
40 + (Math.random() - 0.5) * 10
],
zoom: 9
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment