D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
cphcat
Full window
Github gist
Mapbox - locate the user
Built with
blockbuilder.org
<!DOCTYPE html> <html> <head> <meta charset='utf-8' /> <title></title> <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.39.1/mapbox-gl.js'></script> <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.39.1/mapbox-gl.css' rel='stylesheet' /> <style> body { margin:0; padding:0; } #map { position:absolute; top:0; bottom:0; width:100%; } </style> </head> <body> <div id='map'></div> <script> mapboxgl.accessToken = 'pk.eyJ1IjoiZm94YnkiLCJhIjoiY2o2NHN5eTdwMXAycTJ5bDR1bnE0NzQ0OSJ9.8EiSAtpBcpC3DywBjWpIkw'; var map = new mapboxgl.Map({ container: 'map', // container id style: 'mapbox://styles/mapbox/streets-v9', center: [-96, 37.8], // starting position zoom: 3 // starting zoom }); // Add geolocate control to the map. map.addControl(new mapboxgl.GeolocateControl({ positionOptions: { enableHighAccuracy: true }, trackUserLocation: true })); </script> </body> </html>
https://api.tiles.mapbox.com/mapbox-gl-js/v0.39.1/mapbox-gl.js