mirror of
https://github.com/Viglino/ol-ext.git
synced 2026-01-25 17:36:21 +00:00
85 lines
3.0 KiB
HTML
85 lines
3.0 KiB
HTML
<!DOCTYPE html>
|
|
<!----------------------------------------------------------
|
|
|
|
Copyright (c) 2016 Jean-Marc VIGLINO,
|
|
released under CeCILL-B (french BSD like) licence: http://www.cecill.info/
|
|
|
|
------------------------------------------------------------>
|
|
<html>
|
|
<head>
|
|
<title>OL3-ext: Flashlight!</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<meta name="description" content="Add flashlight effect on OL3 map." />
|
|
<meta name="keywords" content="ol3,canvas,animation,flashlight,effect,interaction" />
|
|
|
|
<!-- jQuery -->
|
|
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
|
|
|
|
<!-- OL3 -->
|
|
<link rel="stylesheet" href="https://openlayers.org/en/master/css/ol.css" />
|
|
<script type="text/javascript" src="https://openlayers.org/en/master/build/ol.js"></script>
|
|
|
|
<script type="text/javascript" src="../interaction/flashlightinteraction.js"></script>
|
|
|
|
<link rel="stylesheet" href="style.css" />
|
|
</head>
|
|
<body >
|
|
<a href="https://github.com/Viglino/ol3-ext"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
|
|
|
|
<a href="../index.html">
|
|
<h1>OL3-ext: Flashlight!</h1>
|
|
</a>
|
|
<p class="info">
|
|
The flashlight interaction add a flahslight effect to reveal the map on mouse move.
|
|
</p>
|
|
|
|
<!-- DIV pour la carte -->
|
|
<div id="map" style="width:600px; height:400px;"></div>
|
|
|
|
<div class="options">
|
|
<h2>Options:</h2>
|
|
<ul><li>
|
|
radius: <input id="radius" type="range" min="30" max="400" value="100" onchange="fl.setRadius(Number(this.value))">
|
|
</li><li>
|
|
color: <select id="color" onchange="fl.setColor({color:this.value})">
|
|
<option value='rgba(0,0,0,0)'>none</option>
|
|
<option value='rgba(255,255,0,0.3)'>yellow</option>
|
|
<option value='rgba(255,0,0,0.3)'>red</option>
|
|
</select>
|
|
</li><li>
|
|
<button onclick="fl.setPosition(false);">Off!</button>
|
|
</li></ul>
|
|
<p>
|
|
<i>Move around to show the map!</i>
|
|
</p>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
// Layers
|
|
var layer = new ol.layer.Tile({
|
|
name: "Natural Earth",
|
|
minResolution: 306,
|
|
source: new ol.source.XYZ(
|
|
{ url: 'https://{a-d}.tiles.mapbox.com/v3/mapbox.natural-earth-hypso-bathy/{z}/{x}/{y}.png',
|
|
attributions: [new ol.Attribution({ html: '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> ' })]
|
|
})
|
|
});
|
|
|
|
// The map
|
|
var map = new ol.Map
|
|
({ target: 'map',
|
|
view: new ol.View
|
|
({ zoom: 5,
|
|
center: [166326, 5992663]
|
|
}),
|
|
layers: [layer]
|
|
});
|
|
|
|
var fl = new ol.interaction.Flashlight({ radius: Number($("#radius").val()), color:$("#color").val() });
|
|
map.addInteraction(fl);
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html> |