ol-ext/examples/map/map.perspective.html
2020-02-27 14:58:29 +01:00

106 lines
3.1 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://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" />
<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 type="range" step=1 min=0 max=30 onchange="map.setPerspective(this.value)" value=0 style="vertical-align: middle;" />
</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]
}),
interactions: ol.interaction.defaults(),
layers: [ layer ]
});
// Create vector layer for select
var vectorSource = new ol.source.Vector({
url: '../data/ignf.json',
format: new ol.format.GeoJSON(),
attributions: [ "&copy; <a href='http://professionnels.ign.fr/bdtopo'>ign.fr</a>" ]
});
var vector = new ol.layer.Vector({
source: vectorSource,
maxResolution: 2
});
map.addLayer(vector);
// Select and draw interaction
map.addInteraction(new ol.interaction.Select({ layers: [vector], condition: ol.events.condition.pointerMove }));
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>