mirror of
https://github.com/Viglino/ol-ext.git
synced 2026-01-25 17:36:21 +00:00
100 lines
3.0 KiB
HTML
100 lines
3.0 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>
|
|
|
|
<!-- Openlayers -->
|
|
<link rel="stylesheet" href="https://openlayers.org/en/latest/css/ol.css" />
|
|
<script type="text/javascript" src="https://openlayers.org/en/latest/build/ol.js"></script>
|
|
<script src="https://cdn.polyfill.io/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>
|
|
|
|
<link rel="stylesheet" href="../style.css" />
|
|
</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>
|
|
</select>
|
|
</li>
|
|
<li>
|
|
<input id="info" value ="Information" />
|
|
<button onclick="ctrl.status($('#info').val())">Show</button>
|
|
</li>
|
|
<li>
|
|
<label>
|
|
<input type="checkbox" onchange="ctrl.show($(this).prop('checked'))" checked="checked" />
|
|
Show/hide
|
|
</label>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
// Layers
|
|
var layer = new ol.layer.Tile({ source: new ol.source.Stamen({ layer: 'watercolor' }) });
|
|
|
|
// 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
|
|
});
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html> |