-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·196 lines (162 loc) · 5.69 KB
/
index.js
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
//Configuracion Inicial
var map = L.map('map').setView([1.063744, -75.262871], 15);
//Mapas bases
var Base1 = L.tileLayer('https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png', {
maxZoom: 22
}).addTo(map);
var mapasBase = {
OppenStreetMap: Base1,
};
var capasGenerales = {
}
const layerGenerales = async (nombre, style, popup) => {
return await fetch(`http://localhost:8080/geoserver/visor/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=visor%3A${nombre}&outputFormat=application%2Fjson`).then(function (res) {
return res.json();
}).then(function (res) {
capasGenerales[nombre] = L.geoJson(res, { style, onEachFeature: popup }).addTo(map);
});
}
const layerEspecifica = async (nombre, style, popup) => {
return await fetch(`http://localhost:8080/geoserver/visor/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=visor%3A${nombre}&outputFormat=application%2Fjson`).then(function (res) {
return res.json();
}).then(function (res) {
capasGenerales[nombre] = L.geoJson(res, { style, onEachFeature: popup });
});
}
async function general() {
/*CAPAS GENERALES*/
//Casa
function styleCasa() {
return {
weight: 2,
opacity: 1,
color: 'yellow',
fillOpacity: 0.8
};
}
function popupCasa(feature, layer) {
layer.bindPopup(feature.properties.nombre);
}
await layerGenerales("Casa", styleCasa, popupCasa);
//Quebradas
function styleQuebradas() {
return {
weight: 2,
opacity: 1,
color: 'blue',
fillOpacity: 0.9
};
}
await layerGenerales("quebradas", styleQuebradas);
//Colindantes
function styleColindantes(feature) {
return {
weight: 2,
opacity: 1,
color: 'olive',
fillOpacity: 0.3
};
}
function popupColindantes(feature, layer) {
layer.bindPopup("Predio de " + feature.properties.nombre);
}
await layerGenerales("colindantes", styleColindantes, popupColindantes);
//Limites
function styleLimites() {
return {
weight: 1,
opacity: 1,
color: 'red',
fillOpacity: 0.1
};
}
function popupLimites(feature, layer) {
layer.bindPopup("Perimetro de la Finca El Vergel " + feature.properties.perimetro + " m2");
}
await layerGenerales("limites", styleLimites, popupLimites);
//Potreros
function stylePotreros() {
return {
weight: 2,
opacity: 1,
color: 'gray',
fillOpacity: 0.4
};
}
function popupPotreros(feature, layer) {
layer.bindPopup("Potrero N° " + feature.id + "<br/> Area: " + feature.properties.area + " m2");
}
await layerGenerales("potreros", stylePotreros, popupPotreros);
//Potreros futuros
await layerEspecifica("potreros_futuros", stylePotreros, popupPotreros);
//Establo
function styleEstablo() {
return {
weight: 2,
opacity: 1,
color: 'black',
fillOpacity: 0.9
};
}
function popupEstablo(feature, layer) {
layer.bindPopup(feature.properties.nombre);
}
await layerGenerales("Establo", styleEstablo, popupEstablo);
/*CAPAS ESPECIFICAS*/
//Reservas Actual
function styleReservas() {
return {
weight: 2,
opacity: 1,
color: 'green',
fillOpacity: 0.7
};
}
function popupReservas(feature, layer) {
layer.bindPopup(feature.id + "<br/> Area: " + feature.properties.area + " m2");
}
await layerEspecifica("reservas_actual", styleReservas, popupReservas);
//Reservas futuras
await layerEspecifica("reservas_futuras", styleReservas, popupReservas);
//Cultivos actual
function styleCultivos() {
return {
weight: 2,
opacity: 1,
color: 'orange',
fillOpacity: 0.5
};
}
function popupCultivos(feature, layer) {
layer.bindPopup("Cultivos de " + feature.properties.nombre + "<br/> Area: " + feature.properties.area + " m2");
}
await layerEspecifica("cultivos_actual", styleCultivos, popupCultivos);
//Cultivos futuros
await layerEspecifica("cultivos_futuros", styleCultivos, popupCultivos);
//Arboles actual
await layerEspecifica("arboles_actual");
//Arboles futuros
await layerEspecifica("arboles_futuros");
//Tanques
await layerEspecifica("tanques");
//Senderos
function styleSenderos() {
return {
weight: 2,
opacity: 1,
color: 'maroon',
fillOpacity: 0.8
};
}
await layerEspecifica("senderos", styleSenderos);
L.control.layers(mapasBase, capasGenerales, {
position: 'topright', // 'topleft', 'bottomleft', 'bottomright'
collapsed: false, // true
}).addTo(map);
L.control.attribution({
prefix: "Visor de La Planificacion Predial de la Finca el Vergel<br/> Yeison Fabian Claros Gonzalez<br/>Yulder Adrian Canamejoy Portilla<br/>Linea de Profundizacion B",
position: 'topleft'
}).addTo(map);
L.control.scale().addTo(map);
};
general();