mirror of
https://github.com/Viglino/ol-ext.git
synced 2025-12-08 19:26:29 +00:00
114 lines
3.3 KiB
HTML
114 lines
3.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<!--
|
|
Copyright (c) 2013 Jean-Marc VIGLINO,
|
|
released under the Beerware license (http://fr.wikipedia.org/wiki/Beerware).
|
|
-->
|
|
<title>ol-ext: Status control</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<meta name="description" content="Show status on the map." />
|
|
<meta name="keywords" content="ol, openlayers, map, status, control, overlay" />
|
|
|
|
<!-- jQuery -->
|
|
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
|
|
<!-- FontAwesome -->
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
|
|
|
<!-- Openlayers -->
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/ol@latest/ol.css" />
|
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ol@latest/dist/ol.js"></script>
|
|
<script src="/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL,Object.assign"></script>
|
|
|
|
<!-- ol-ext -->
|
|
<link rel="stylesheet" href="../../dist/ol-ext.css" />
|
|
<script type="text/javascript" src="../../dist/ol-ext.js"></script>
|
|
<!-- Pointer events polyfill for old browsers, see https://caniuse.com/#feat=pointer -->
|
|
<script src="https://unpkg.com/elm-pep"></script>
|
|
|
|
<link rel="stylesheet" href="../style.css" />
|
|
<style>
|
|
.debug {
|
|
right: .5em;
|
|
top: 2em;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body >
|
|
<a href="https://github.com/Viglino/ol-ext" class="icss-github-corner"><i></i></a>
|
|
|
|
<a href="../../index.html">
|
|
<h1>ol-ext: Status control</h1>
|
|
</a>
|
|
<div class="info">
|
|
<i>ol.control.Status</i> lets display a status over the map, useful for debugging purposes.
|
|
</div>
|
|
|
|
<!-- DIV pour la carte -->
|
|
<div id="map" style="width:100%; height:400px;"></div>
|
|
|
|
<div class="options">
|
|
<h2>Options:</h2>
|
|
<ul>
|
|
<li>
|
|
Position:
|
|
<select onchange="ctrl.setPosition(this.value)">
|
|
<option value='top'>top</option>
|
|
<option value='bottom'>bottom</option>
|
|
<option value='left'>left</option>
|
|
<option value='right'>right</option>
|
|
<option value='center'>center</option>
|
|
</select>
|
|
</li>
|
|
<li>
|
|
<input id="info" value ="Information" />
|
|
<button onclick="ctrl.status($('#info').val())">Show</button>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
// Layers
|
|
var layer = new ol.layer.Geoportail('ORTHOIMAGERY.ORTHOPHOTOS');
|
|
|
|
// The map
|
|
var map = new ol.Map ({
|
|
target: 'map',
|
|
view: new ol.View ({
|
|
zoom: 13,
|
|
center: [649083, 5408224]
|
|
}),
|
|
layers: [layer]
|
|
});
|
|
|
|
var ctrl = new ol.control.Status();
|
|
map.addControl(ctrl);
|
|
// Show information on each frame
|
|
map.on('postrender', function(e) {
|
|
// console.log(e)
|
|
var c = map.getView().getCenter();
|
|
ctrl.status({
|
|
center: [Math.round(c[0]),Math.round(c[1])],
|
|
lonlat: ol.coordinate.toStringHDMS(ol.proj.toLonLat(c)),
|
|
zoom: map.getView().getZoom(),
|
|
resolution: map.getView().getResolution().toFixed(4),
|
|
angle: Math.round(map.getView().getRotation()*180/Math.PI*100)/100,
|
|
size: map.getSize(),
|
|
animate: e.frameState.animate
|
|
});
|
|
});
|
|
|
|
var toggle = new ol.control.Toggle({
|
|
html: '<i class="fa fa-bug"></i>',
|
|
className: 'debug',
|
|
onToggle: function(b) {
|
|
ctrl.setVisible(!b);
|
|
}
|
|
})
|
|
map.addControl(toggle)
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html> |