mirror of
https://github.com/Viglino/ol-ext.git
synced 2025-12-08 19:26:29 +00:00
113 lines
3.1 KiB
HTML
113 lines
3.1 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<!--
|
|
Copyright (c) 2019 Jean-Marc VIGLINO,
|
|
released under CeCILL-B (french BSD like) licence: http://www.cecill.info/
|
|
-->
|
|
<title>ol-ext: MapZone</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<meta name="description" content="Simply jump from a mapzone to another." />
|
|
<meta name="keywords" content="ol, openlayers, map, zone, jump" />
|
|
|
|
<!-- jQuery -->
|
|
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
|
|
|
|
<!-- 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>
|
|
|
|
|
|
<!-- 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>
|
|
#map, .zones {
|
|
width: 980px;
|
|
}
|
|
.zones {
|
|
clear:both;
|
|
text-align: center;
|
|
background: #ccc;
|
|
padding: .2em 0 1em;
|
|
box-sizing: border-box;
|
|
}
|
|
.ol-control.ol-mapzone button i {
|
|
color: rgb(102,102,102);
|
|
}
|
|
.zones .ol-mapzonezone {
|
|
margin: 4px;
|
|
}
|
|
.zones .ol-mapzonezone:hover {
|
|
box-shadow: 0 0 0 .5em #fff;
|
|
}
|
|
</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: MapZone control</h1>
|
|
</a>
|
|
<div class="info">
|
|
A control to jump from a map zone to another.
|
|
<ul>
|
|
<li>
|
|
The <i>zones</i> options lets you pass an array of zones objects with a name and an extent.
|
|
</li>
|
|
<li>
|
|
The <i>centerOnClick</i> options will center the map on the clicked zone.
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<!-- DIV pour la carte -->
|
|
<div id="map" style="height:600px;"></div>
|
|
<div class="zones">
|
|
<h2>French overseas departments and territories</h2>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
|
|
// Two base layers
|
|
var ign = new ol.layer.Geoportail({ layer: 'ORTHOIMAGERY.ORTHOPHOTOS' });
|
|
|
|
// The map
|
|
var map = new ol.Map({
|
|
target: 'map',
|
|
view: new ol.View({
|
|
zoom: 6,
|
|
center: [173664, 6166327]
|
|
}),
|
|
layers: [ign]
|
|
});
|
|
|
|
var zone = new ol.control.MapZone({
|
|
layer: function(z) { return new ol.layer.Geoportail({ layer: 'ORTHOIMAGERY.ORTHOPHOTOS' }) },
|
|
zones: [{
|
|
title: 'Métropole',
|
|
extent: [ -5.318421740712579, 41.16082274292913, 9.73284186155716, 51.21957336557702 ]
|
|
}].concat(ol.control.MapZone.zones.DOM)
|
|
});
|
|
map.addControl(zone);
|
|
zone.on('select', function(e) {
|
|
console.log('click ' + e.zone.title +' ('+e.index+')');
|
|
});
|
|
|
|
map.addControl( new ol.control.MapZone({
|
|
layer: function() { return new ol.layer.Geoportail({ layer: 'ORTHOIMAGERY.ORTHOPHOTOS' }) },
|
|
zones: ol.control.MapZone.zones.DOMTOM,
|
|
target: $('.zones').get(0)
|
|
}));
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html> |