-
Notifications
You must be signed in to change notification settings - Fork 0
/
indexOL.php
115 lines (95 loc) · 3.46 KB
/
indexOL.php
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
<!DOCTYPE html>
<html lang="es">
<head>
<title>Pruebas Mapa OpenLayers 3</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="css/ol.css" />
<link rel="stylesheet" href="css/estilos.css" />
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/ol.js" type="text/javascript"></script>
</head>
<body>
<div id="mapCanvas"></div>
<script>
var map;
var aa;
function init() {
map = new ol.Map({
target: 'mapCanvas',
renderer: 'canvas',
view: new ol.View({
projection: 'EPSG:3857',
center: ol.proj.transform([-3.693107, 40.419356], 'EPSG:4326', 'EPSG:3857'),
zoom: 12
})
});
var newLayer = new ol.layer.Tile({
source: new ol.source.OSM()
});
map.addLayer(newLayer);
var styles = {
0: new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(255, 0, 0, 0.5)'
}),
stroke: new ol.style.Stroke({
width: 1,
color: 'rgba(255, 0, 0, 1)'
})
}),
1: new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(0, 255, 0, 0.5)'
}),
stroke: new ol.style.Stroke({
width: 1,
color: 'rgba(0, 255, 0, 1)'
})
}),
2: new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(0, 0, 255, 0.5)'
}),
stroke: new ol.style.Stroke({
width: 1,
color: 'rgba(0, 0, 255, 1)'
})
})
};
var geoLayer = new ol.layer.Vector({
source: new ol.source.GeoJSON({
projection: 'EPSG:3857',
url: './geojson/cruces.json'
}),
style: function (feature) {
var aux = feature.get('REGULADOR') % 3;
var s = styles[aux];
return [s];
}
});
aa = styles;
map.addLayer(geoLayer);
}
function montaVector() {
var sol = {};
var f = map.getLayers().getArray()[1].getSource().getFeatures();
for (var i = 0; i < f.length; i++) {
sol[f[i].get('IDELEM')] = f[i];
}
return sol;
}
function cambiaColores(v) {
for (var i in v) {
v[i].set('REGULADOR', Math.round(Math.random() * 100));
}
}
var v;
function flash() {
v = montaVector();
setInterval(function () {
cambiaColores(v);
}, 1000);
}
</script>
</body>
</html>