Created
November 12, 2015 17:23
-
-
Save nbumbarger/46adece271f556be7dc3 to your computer and use it in GitHub Desktop.
Gara Djebilet PCA (Mapbox slider, image processing example)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>Gara Djebilet PCA</title> | |
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> | |
<script src='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.js'></script> | |
<link href='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.css' rel='stylesheet' /> | |
<style> | |
body { margin:0; padding:0; } | |
#map { position:absolute; top:0; bottom:0; width:100%; } | |
</style> | |
</head> | |
<body> | |
<style> | |
body {font-family:sans-serif;} | |
input[type=range]{ | |
-webkit-appearance:none; | |
height:3px; | |
background:#fff; | |
border-radius:3px; | |
} | |
input[type=range]::-webkit-slider-thumb{ | |
-webkit-appearance:none; | |
background-color:#ddd; | |
box-shadow: 0 0 4px #333; | |
height:20px; | |
width:20px; | |
border-radius:50%; | |
} | |
input[type=range]:focus { | |
outline: none; | |
} | |
p { | |
color:#fff; | |
position:absolute; | |
} | |
.left { | |
left:25%; | |
} | |
.right { | |
right:25%; | |
} | |
.range { | |
position:absolute; | |
width:100%; | |
top:95%; | |
z-index:99; | |
} | |
</style> | |
<div id='map'></div> | |
<p class='left'>PCA 5 2 4 = RGB</p> | |
<p class='right'>True Color</p> | |
<input id='range' class='range' type='range' min='0' max='1.0' step='any' /> | |
<script> | |
L.mapbox.accessToken = 'pk.eyJ1IjoiYXN0cm9kaWdpdGFsIiwiYSI6ImNVb1B0ZkEifQ.IrJoULY2VMSBNFqHLrFYew'; | |
var map = L.mapbox.map('map', 'mapbox.satellite') | |
.setView([26.9, -7.2], 11); | |
var original = L.mapbox.tileLayer('astrodigital.o4po94dl'), | |
overlay = L.mapbox.tileLayer('astrodigital.zivhd7vi'), | |
range = document.getElementById('range'); | |
function clip() { | |
var nw = map.containerPointToLayerPoint([0, 0]), | |
se = map.containerPointToLayerPoint(map.getSize()), | |
clipX = nw.x + (se.x - nw.x) * range.value; | |
overlay.getContainer().style.clip = 'rect(' + [nw.y, clipX, se.y, nw.x].join('px,') + 'px)'; | |
} | |
range['oninput' in range ? 'oninput' : 'onchange'] = clip; | |
map.addLayer(original) | |
.addLayer(overlay); | |
map.on('move', clip); | |
clip(); | |
</script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment