-
Notifications
You must be signed in to change notification settings - Fork 471
/
Copy pathmap.layer.3D.2.html
134 lines (122 loc) · 3.67 KB
/
map.layer.3D.2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<DOCTYPE html>
<html>
<head>
<!--
Copyright (c) 2015-2019 Jean-Marc VIGLINO,
released under CeCILL-B (french BSD like) licence: http://www.cecill.info/
-->
<title>Layer 3D</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="2.5D/3D source on an ol map" />
<meta name="keywords" content="ol, openlayers, layer, vector, 3D, 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 {
position:fixed;
top: 4em;
left: 0;
right:0;
bottom:0;
margin:0;
}
.info {
position: fixed;
right: 0.5em;
top: 4em;
width: 300px;
z-index: 1;
}
.loading {
background: #fff;
border: 2px solid #369;
left: 50%;
margin: -2em -100px;
padding: 0.5em;
position: fixed;
text-align: center;
top: 50%;
width: 200px;
z-index: 1;
box-sizing: border-box;
box-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}
</style>
</head>
<body >
<a href="https://github.com/Viglino/ol-ext" class="icss-github-corner"><i></i></a>
<a href="../../index.html">
<h1>Layer 3D</h1>
</a>
<div class="info">
This example use an <i>ol/layer/Vector3D</i> to display a source in a 2.5/3D style.
<br />
Buildings from <a href="http://professionnels.ign.fr/bdtopo">BDTopo © IGN-France</a>.
<br />
POI informations from <a href="https://www.wikipedia.org/">WikiPedia</a>
<br/>
<button onclick="doAnime();">Animate!</button>
</div>
<!-- DIV pour la carte -->
<div id="map"></div>
<div class="loading">Please wait while loading data...</div>
<script type="text/javascript">
// The map
var map = new ol.Map ({
target: 'map',
view: new ol.View ({
zoom: 13,
center: [260841, 6250141]
}),
layers: [ new ol.layer.Tile({ name:"OSM", source: new ol.source.OSM() })]
});
// Create layer
var vectorSource = new ol.source.Vector({
attributions: [ "© <a href='https://cadastre.data.gouv.fr/dvf'>DGFiP</a>" ]
});
$.getJSON('../data/dvf-75-2017-100m.geojson').done(function(data){
var features = (new ol.format.GeoJSON()).readFeatures(data);
features.forEach(function (f) {
f.getGeometry().transform('EPSG:4326', map.getView().getProjection());
// f.setGeometry(f.getGeometry().getInteriorPoint());
});
vectorSource.addFeatures(features);
$('.loading').hide();
doAnime();
});
var vector = new ol.layer.Vector3D({
source: vectorSource,
style: new ol.style.Style({
stroke: new ol.style.Stroke({
width: 5,
color: [255,0,0,.5],
//lineCap: 'round'
}),
geometry: function(f) {
return f.getGeometry().getInteriorPoint();
}
}),
//center: [.5,1.5],
height: 0,
//maxResolution: 40,
defaultHeight: 0
});
map.addLayer(vector);
var height = 0;
function doAnime() {
if (vector.animating()) return;
height = height ? 0 : function(f) { return f.get('nb')*20; };
vector.animate({ height:height });
}
</script>
</body>
</html>