Skip to content

Instantly share code, notes, and snippets.

@danswick
danswick / README.md
Last active January 25, 2017 02:28
Compare mapbox normal directions and traffic-optimized directions

Click once to set a starting point, then click again to set a destination. Click a third time to start over.

  • Blue: traffic optimized
  • Red: regular ol route
@danswick
danswick / README.md
Last active January 6, 2023 09:04
Mapbox GL JS interactive map.resize()

Intentionally break your map canvas using the resize container button, then fix it again using the fix map button. This little demo is designed to show off how Mapbox GL JS's map.resize() method can fix a squished or stretched map canvas by telling the map to 1) check the size of its container, then 2) trigger a re-render. This method is useful for applications where the map's container might be resized interactively through a sliding, expanding, contracting, or interactively hidden HTML element.

@danswick
danswick / README.md
Last active October 11, 2017 07:04
Get weather conditions along a route

Click to get a route and retrieve weather information at a given interval along the way. Currently displaying wind speed.

Includes superfluous data point extrusions.

<!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.21.0/mapbox-gl.js'></script>
<script src='mapbox-gl-draw.js'></script>
<script src="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v1.3.0/mapbox-gl-geocoder.js"></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.21.0/mapbox-gl.css' rel='stylesheet' />
@danswick
danswick / index.html
Created September 1, 2016 01:03
Put reverse geocoding results in GL JS popup
<!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.23.0/mapbox-gl.js'></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.23.0/mapbox-gl.css' rel='stylesheet' />
<style>
@danswick
danswick / icon.png
Last active April 19, 2023 14:29
Save GeoJSON from Mapbox GL Draw
icon.png
@danswick
danswick / index.html
Last active March 17, 2017 19:37
raster tiles with transparency on a GL map
<!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.21.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.21.0/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@danswick
danswick / README.md
Last active November 2, 2017 04:01
Update a popup's content in Mapbox.js

Use setPopupContent() to update a popup periodically.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.