ol-ext/examples/filter/map.filter.texture.html
2018-01-31 10:07:24 +01:00

109 lines
3.7 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<!----------------------------------------------------------
Copyright (c) 2016-2018 Jean-Marc VIGLINO,
released under CeCILL-B (french BSD like) licence: http://www.cecill.info/
------------------------------------------------------------>
<title>ol-ext: Texture filter </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Crop and mask filter on an ol map or layer." />
<meta name="keywords" content="ol3, filter, crop, mask" />
<link rel="stylesheet" href="../style.css" />
<!-- jQuery -->
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
<!-- FontAwesome -->
<link rel="stylesheet" href="https://rawgit.com/FortAwesome/Font-Awesome/master/css/font-awesome.min.css" type="text/css" />
<!-- Openlayers -->
<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>
<!-- ol-ext -->
<script type="text/javascript" src="../../dist/ol-ext.js"></script>
<style>
input[type="range"]
{ vertical-align: middle;
}
input[type="number"]
{ width:4em;
}
</style>
</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>ol-ext: Texture filter</h1>
</a>
<div class="info">
<i>ol.filter.Texture</i> add a texture effect on the map.
</div>
<!-- Map div -->
<div id="map" style="width:600px; height:400px;"></div>
<div class="options" >
<ul><li>
Texture:
<select id="texture" onchange="setFilter()">
<option value="wood">wood</option>
<option value="stone">stone</option>
<option value="rust">rust</option>
<option value="metal">metal</option>
<option value="cardboard">cardboard</option>
<option value="notebook">notebook</option>
<option value="https://opengameart.org/sites/default/files/parchment-gold.png.preview.jpg">parchemin</option>
<option value="https://opengameart.org/sites/default/files/WhiteIrregular_T.jpg">paving</option>
</select>
</li><li>
<input id="active" type="checkbox" checked="checked" /><label for="active"> active</label>
</li><li>
<input id="rotate" type="checkbox" checked="checked" /><label for="rotate"> rotate with view</label>
</li><li>
Opacity: <input id="opacity" type="range" min="0" max="1" step="0.1" value="0.7" />
</li></ul>
</div>
<script type="text/javascript">
$("input").on('change', setFilter);
var osm = new ol.layer.Tile({ source: new ol.source.OSM() });
// The map
var map = new ol.Map
({ target: 'map',
view: new ol.View
({ zoom: 8,
center: [247044, 6549736.]
}),
layers:
[ new ol.layer.Tile({ source: new ol.source.Stamen({ layer: 'watercolor' }) }),
osm
]
});
// Custom filter
var filter = new ol.filter.Texture();
map.addFilter(filter);
function setFilter()
{ filter.setActive($("#active").prop('checked'));
filter.setFilter(
{ src: $("#texture").val(),
rotateWithView: $("#rotate").prop('checked'),
opacity: Number($("#opacity").val())
});
}
setFilter();
</script>
</body>
</html>