mirror of
https://github.com/Viglino/ol-ext.git
synced 2025-12-08 19:26:29 +00:00
117 lines
3.3 KiB
HTML
117 lines
3.3 KiB
HTML
<DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<!--
|
|
Copyright (c) 2015-2019 Jean-Marc VIGLINO,
|
|
released under CeCILL-B (french BSD like) licence: http://www.cecill.info/
|
|
-->
|
|
<title>Perspective ol Map</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<meta name="description" content="Perspective ol map" />
|
|
<meta name="keywords" content="openlayers, layer, 3D, perspective, animation" />
|
|
|
|
<!-- 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 {
|
|
width: 800px;
|
|
height: 600px;
|
|
z-index: 0;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body >
|
|
<a href="https://github.com/Viglino/ol-ext" class="icss-github-corner"><i></i></a>
|
|
<a href="../../index.html">
|
|
<h1>Perspective ol map</h1>
|
|
</a>
|
|
<div class="info">
|
|
<p>
|
|
<i>ol/PerspectiveMap</i> displays a map with a perspective effect by pitching the map.
|
|
</p>
|
|
<p>
|
|
<span class="experimental">Experimental</span> tested on Chrome and Edge. Not working on Firefox.
|
|
</p>
|
|
</div>
|
|
|
|
<!-- DIV pour la carte -->
|
|
<div id="map"></div>
|
|
|
|
<div class="options">
|
|
<ul>
|
|
<li>
|
|
<label>Perspective:</label>
|
|
<input id="angle" type="range" step=1 min=0 max=30 onchange="map.setPerspective(this.value)" value=0 style="vertical-align: middle;" />
|
|
</li>
|
|
<li><i>use alt + drag to tilt the map...</i></li>
|
|
</ul>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
var layer = new ol.layer.Tile({ name:"OSM", source: new ol.source.OSM() });
|
|
|
|
// The map
|
|
var map = new ol.PerspectiveMap({
|
|
target: 'map',
|
|
view: new ol.View ({
|
|
zoom: 19,
|
|
center: [-245406, 5986536]// [-245575, 5986863], //[-244777, 5989809]
|
|
}),
|
|
layers: [ layer ]
|
|
});
|
|
|
|
map.on('change:perspective', function(e) {
|
|
if (!e.animating) $('#angle').val(e.angle);
|
|
})
|
|
|
|
// Create vector layer for select
|
|
var vectorSource = new ol.source.Vector({
|
|
url: '../data/ignf.json',
|
|
format: new ol.format.GeoJSON(),
|
|
attributions: [ "© <a href='http://professionnels.ign.fr/bdtopo'>ign.fr</a>" ]
|
|
});
|
|
var vector = new ol.layer.VectorImage({
|
|
source: vectorSource,
|
|
maxResolution: 2
|
|
});
|
|
map.addLayer(vector);
|
|
|
|
// Select and draw interaction
|
|
map.addInteraction(new ol.interaction.Select({
|
|
layers: [vector],
|
|
condition: function (e) {
|
|
return (ol.events.condition.pointerMove(e) && !ol.events.condition.altKeyOnly(e))
|
|
}
|
|
}));
|
|
map.addInteraction(new ol.interaction.Draw({ type: 'LineString' }))
|
|
|
|
// An overlay
|
|
var place = new ol.Overlay.Placemark ({
|
|
contentColor: '#000'
|
|
});
|
|
map.addOverlay(place);
|
|
map.on('click', function(e) {
|
|
place.show(e.coordinate);
|
|
});
|
|
|
|
// Fullscreen
|
|
// map.addControl(new ol.control.FullScreen({ source: 'map' }));
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html> |