vue-geojson-view-ts 1.3.19 → 1.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +321 -321
- package/dist/components/MapSearchAddress.vue.d.ts +1 -1
- package/dist/components/MapView.vue.d.ts +58 -20
- package/dist/data/bolivia.geojson +2084 -2084
- package/dist/data/cities/be.geojson +246 -246
- package/dist/data/cities/cbba.geojson +165 -165
- package/dist/data/cities/ch.geojson +170 -170
- package/dist/data/cities/lp.geojson +314 -314
- package/dist/data/cities/or.geojson +253 -253
- package/dist/data/cities/pd.geojson +164 -164
- package/dist/data/cities/pt.geojson +379 -379
- package/dist/data/cities/sc.geojson +224 -224
- package/dist/data/cities/tj.geojson +86 -86
- package/dist/pin.svg +4 -4
- package/dist/style.css +1 -1
- package/dist/vite-env.d.ts +1 -1
- package/dist/vue-geojson-view-ts.js +10486 -10335
- package/dist/vue-geojson-view-ts.umd.cjs +23 -20
- package/package.json +78 -78
- package/src/components/CoordinatesVerifyPolygon.vue +86 -86
- package/src/components/MapHeatComponent.vue +664 -664
- package/src/components/MapSearchAddress.vue +309 -309
- package/src/components/MapView.vue +1054 -715
|
@@ -1,664 +1,664 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="map-container" :style="`height:${configurationMap?.height}`">
|
|
3
|
-
<div ref="map-root" style="width: 100%; height: 100%; position: relative">
|
|
4
|
-
<div
|
|
5
|
-
v-show="loadMapa.country !== 'Bolivia'"
|
|
6
|
-
class="btn-zoom-container ol-control"
|
|
7
|
-
>
|
|
8
|
-
<button
|
|
9
|
-
title="Ir a la ciudad"
|
|
10
|
-
class="jl2-button-map"
|
|
11
|
-
@click="irACiudad"
|
|
12
|
-
>
|
|
13
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
|
14
|
-
<path
|
|
15
|
-
d="M278.6 9.4c-12.5-12.5-32.8-12.5-45.3 0l-64 64c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l9.4-9.4V224H109.3l9.4-9.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-64 64c-12.5 12.5-12.5 32.8 0 45.3l64 64c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-9.4-9.4H224v114.8l-9.4-9.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l64 64c12.5 12.5 32.8 12.5 45.3 0l64-64c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-9.4 9.4V288h114.8l-9.4 9.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l64-64c12.5-12.5 12.5-32.8 0-45.3l-64-64c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l9.4 9.4H288V109.3l9.4 9.4c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-64-64z"
|
|
16
|
-
/>
|
|
17
|
-
</svg>
|
|
18
|
-
</button>
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
|
-
<div class="type-map-container ol-control">
|
|
22
|
-
<!-- button para mapa con marcadores -->
|
|
23
|
-
<button
|
|
24
|
-
title="Mapa con Marcador"
|
|
25
|
-
class="jl2-button-map"
|
|
26
|
-
:class="{ 'jl2-button-map-select': type == '1' }"
|
|
27
|
-
@click="() => (type = '1')"
|
|
28
|
-
>
|
|
29
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512">
|
|
30
|
-
<path
|
|
31
|
-
d="M215.7 499.2C267 435 384 279.4 384 192 384 86 298 0 192 0S0 86 0 192c0 87.4 117 243 168.3 307.2 12.3 15.3 35.1 15.3 47.4 0zM192 128a64 64 0 1 1 0 128 64 64 0 1 1 0-128z"
|
|
32
|
-
/>
|
|
33
|
-
</svg>
|
|
34
|
-
</button>
|
|
35
|
-
<!-- button para mapa de calor -->
|
|
36
|
-
<button
|
|
37
|
-
title="Mapa de Calor"
|
|
38
|
-
class="jl2-button-map"
|
|
39
|
-
:class="{ 'jl2-button-map-select': type == '0' }"
|
|
40
|
-
@click="() => (type = '0')"
|
|
41
|
-
>
|
|
42
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512">
|
|
43
|
-
<path
|
|
44
|
-
d="m153.6 29.9 16-21.3c4-5.4 10.4-8.6 17.1-8.6C198.4 0 208 9.6 208 21.3v22.2c0 13.1 5.4 25.7 14.9 34.7l84.7 80.8c48.8 46.6 76.4 111.2 76.4 178.7C384 434 306 512 209.7 512H192C86 512 0 426 0 320v-3.8c0-48.8 19.4-95.6 53.9-130.1l3.5-3.5c4.2-4.2 10-6.6 16-6.6 12.5 0 22.6 10.1 22.6 22.6V288c0 35.3 28.7 64 64 64s64-28.7 64-64v-3.9c0-18-7.2-35.3-19.9-48l-38.6-38.6c-24-24-37.5-56.7-37.5-90.7 0-27.7 9-54.8 25.6-76.9z"
|
|
45
|
-
/>
|
|
46
|
-
</svg>
|
|
47
|
-
</button>
|
|
48
|
-
</div>
|
|
49
|
-
|
|
50
|
-
<!-- Botón de configuraciones -->
|
|
51
|
-
<div
|
|
52
|
-
class="btn-settings ol-control"
|
|
53
|
-
v-show="!showSetting && type === '0'"
|
|
54
|
-
>
|
|
55
|
-
<button
|
|
56
|
-
title="Ver Opciones"
|
|
57
|
-
class="jl2-button-map"
|
|
58
|
-
@click="toggleSettings"
|
|
59
|
-
>
|
|
60
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
|
61
|
-
<path
|
|
62
|
-
d="M495.9 166.6c3.2 8.7.5 18.4-6.4 24.6l-43.3 39.4c1.1 8.3 1.7 16.8 1.7 25.4s-.6 17.1-1.7 25.4l43.3 39.4c6.9 6.2 9.6 15.9 6.4 24.6-4.4 11.9-9.7 23.3-15.8 34.3l-4.7 8.1c-6.6 11-14 21.4-22.1 31.2-5.9 7.2-15.7 9.6-24.5 6.8l-55.7-17.7c-13.4 10.3-28.2 18.9-44 25.4l-12.5 57.1c-2 9.1-9 16.3-18.2 17.8-13.8 2.3-28 3.5-42.5 3.5s-28.7-1.2-42.5-3.5c-9.2-1.5-16.2-8.7-18.2-17.8l-12.5-57.1c-15.8-6.5-30.6-15.1-44-25.4l-55.6 17.8c-8.8 2.8-18.6.3-24.5-6.8-8.1-9.8-15.5-20.2-22.1-31.2l-4.7-8.1c-6.1-11-11.4-22.4-15.8-34.3-3.2-8.7-.5-18.4 6.4-24.6l43.3-39.4c-1.1-8.4-1.7-16.9-1.7-25.5s.6-17.1 1.7-25.4l-43.3-39.4c-6.9-6.2-9.6-15.9-6.4-24.6 4.4-11.9 9.7-23.3 15.8-34.3l4.7-8.1c6.6-11 14-21.4 22.1-31.2 5.9-7.2 15.7-9.6 24.5-6.8l55.7 17.7c13.4-10.3 28.2-18.9 44-25.4l12.5-57.1c2-9.1 9-16.3 18.2-17.8C227.3 1.2 241.5 0 256 0s28.7 1.2 42.5 3.5c9.2 1.5 16.2 8.7 18.2 17.8l12.5 57.1c15.8 6.5 30.6 15.1 44 25.4l55.7-17.7c8.8-2.8 18.6-.3 24.5 6.8 8.1 9.8 15.5 20.2 22.1 31.2l4.7 8.1c6.1 11 11.4 22.4 15.8 34.3zM256 336a80 80 0 1 0 0-160 80 80 0 1 0 0 160z"
|
|
63
|
-
/>
|
|
64
|
-
</svg>
|
|
65
|
-
</button>
|
|
66
|
-
</div>
|
|
67
|
-
<!-- Opciones de configuraciones -->
|
|
68
|
-
<div class="control-container" v-show="type === '0' && showSetting">
|
|
69
|
-
<a @click="toggleSettings" class="ol-popup-closer"></a>
|
|
70
|
-
<div class="map-flex">
|
|
71
|
-
<label>Tamaño del radio</label>
|
|
72
|
-
<input
|
|
73
|
-
id="radius"
|
|
74
|
-
type="range"
|
|
75
|
-
min="1"
|
|
76
|
-
max="50"
|
|
77
|
-
step="1"
|
|
78
|
-
v-model="radius"
|
|
79
|
-
/>
|
|
80
|
-
</div>
|
|
81
|
-
<div class="map-flex">
|
|
82
|
-
<label>Difuminado</label>
|
|
83
|
-
<input
|
|
84
|
-
id="blur"
|
|
85
|
-
type="range"
|
|
86
|
-
min="1"
|
|
87
|
-
max="50"
|
|
88
|
-
step="1"
|
|
89
|
-
v-model="blur"
|
|
90
|
-
/>
|
|
91
|
-
</div>
|
|
92
|
-
</div>
|
|
93
|
-
<!-- Tag casos Vinculados -->
|
|
94
|
-
<div
|
|
95
|
-
class="cant-casos ol-attribution ol-unselectable ol-control ol-uncollapsible"
|
|
96
|
-
>
|
|
97
|
-
<p class="text-cantidad">
|
|
98
|
-
<span class="ol-bold">Casos: </span>{{ cantidad }}
|
|
99
|
-
</p>
|
|
100
|
-
</div>
|
|
101
|
-
</div>
|
|
102
|
-
<div id="popup" class="ol-popup" v-show="type === '1'">
|
|
103
|
-
<a id="popup-closer" class="ol-popup-closer"></a>
|
|
104
|
-
<div id="popup-content"></div>
|
|
105
|
-
</div>
|
|
106
|
-
</div>
|
|
107
|
-
</template>
|
|
108
|
-
|
|
109
|
-
<script lang="ts">
|
|
110
|
-
import "ol/ol.css";
|
|
111
|
-
import View from "ol/View";
|
|
112
|
-
import Map from "ol/Map";
|
|
113
|
-
import HeatmapLayer from "ol/layer/Heatmap";
|
|
114
|
-
import OSM from "ol/source/OSM";
|
|
115
|
-
import TileLayer from "ol/layer/Tile";
|
|
116
|
-
import VectorSource from "ol/source/Vector";
|
|
117
|
-
import GeoJSON from "ol/format/GeoJSON";
|
|
118
|
-
import { fromLonLat } from "ol/proj";
|
|
119
|
-
import Fill from "ol/style/Fill";
|
|
120
|
-
import Stroke from "ol/style/Stroke";
|
|
121
|
-
import Text from "ol/style/Text";
|
|
122
|
-
import VectorLayer from "ol/layer/Vector";
|
|
123
|
-
import Overlay from "ol/Overlay";
|
|
124
|
-
import { Icon, Style } from "ol/style";
|
|
125
|
-
|
|
126
|
-
import {
|
|
127
|
-
Attribution,
|
|
128
|
-
FullScreen,
|
|
129
|
-
defaults as defaultControls,
|
|
130
|
-
} from "ol/control";
|
|
131
|
-
import { defineComponent } from "vue";
|
|
132
|
-
import { markerDefault } from "../helpers/imgBase64";
|
|
133
|
-
|
|
134
|
-
export default defineComponent({
|
|
135
|
-
name: "MapHeat",
|
|
136
|
-
props: {
|
|
137
|
-
coords: Object as any,
|
|
138
|
-
loadMapa: Object as any,
|
|
139
|
-
typeMap: String,
|
|
140
|
-
abrirCerrarLoader: Function,
|
|
141
|
-
onClickMarket: Function,
|
|
142
|
-
configurationMap: {
|
|
143
|
-
default: () => {
|
|
144
|
-
return {
|
|
145
|
-
strokeColor: "#f47521",
|
|
146
|
-
copyright: "© 2021 Desarrollado por UTIC - Ministerio Público",
|
|
147
|
-
height: "250px",
|
|
148
|
-
maxZoom: 20,
|
|
149
|
-
iconMarker: {
|
|
150
|
-
image: markerDefault,
|
|
151
|
-
color: "#f47521",
|
|
152
|
-
iconUrl: "/image/gmap01.png",
|
|
153
|
-
iconSize: [25, 41],
|
|
154
|
-
iconAnchor: [12, 41],
|
|
155
|
-
scale: 1,
|
|
156
|
-
class: "",
|
|
157
|
-
type: "image",
|
|
158
|
-
},
|
|
159
|
-
dragMarker: true,
|
|
160
|
-
};
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
data: () => ({
|
|
165
|
-
// store OL objects on the component instance
|
|
166
|
-
radius: 10,
|
|
167
|
-
blur: 20,
|
|
168
|
-
zoom: 5,
|
|
169
|
-
type: "0",
|
|
170
|
-
olMap: null as any,
|
|
171
|
-
heatLayer: null as any,
|
|
172
|
-
pointLayer: null as any,
|
|
173
|
-
countryLayer: null as any,
|
|
174
|
-
overlay: null as any,
|
|
175
|
-
showSetting: false,
|
|
176
|
-
cantidad: 0,
|
|
177
|
-
}),
|
|
178
|
-
watch: {
|
|
179
|
-
radius(value) {
|
|
180
|
-
this.setRadius(value);
|
|
181
|
-
},
|
|
182
|
-
blur(value) {
|
|
183
|
-
this.setBlur(value);
|
|
184
|
-
},
|
|
185
|
-
coords(value) {
|
|
186
|
-
this.cantidad = value.features.length;
|
|
187
|
-
this.updateSource(value);
|
|
188
|
-
this.updatePointSource(value);
|
|
189
|
-
},
|
|
190
|
-
loadMapa(val) {
|
|
191
|
-
this.changeCountryLayer(val);
|
|
192
|
-
},
|
|
193
|
-
typeMap(val) {
|
|
194
|
-
this.changeTypeMap(val);
|
|
195
|
-
},
|
|
196
|
-
type(type) {
|
|
197
|
-
this.changeTypeMap(type);
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
methods: {
|
|
201
|
-
changeTypeMap(type: string) {
|
|
202
|
-
if (type === "0") {
|
|
203
|
-
this.heatLayer.setVisible(true);
|
|
204
|
-
this.pointLayer.setVisible(false);
|
|
205
|
-
this.olMap.removeEventListener("click", this.onClickListener);
|
|
206
|
-
} else {
|
|
207
|
-
this.heatLayer.setVisible(false);
|
|
208
|
-
this.pointLayer.setVisible(true);
|
|
209
|
-
this.initClick();
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
initMap() {
|
|
213
|
-
const attributions = `<span class='map-copyright-text' >${this.configurationMap.copyright}</span>`;
|
|
214
|
-
const style = new Style({
|
|
215
|
-
stroke: new Stroke({
|
|
216
|
-
color: this.configurationMap.strokeColor,
|
|
217
|
-
width: 3,
|
|
218
|
-
}),
|
|
219
|
-
text: new Text({
|
|
220
|
-
font: "12px Roboto",
|
|
221
|
-
fill: new Fill({
|
|
222
|
-
color: "#000",
|
|
223
|
-
}),
|
|
224
|
-
stroke: new Stroke({
|
|
225
|
-
color: "#fff",
|
|
226
|
-
width: 1,
|
|
227
|
-
}),
|
|
228
|
-
}),
|
|
229
|
-
});
|
|
230
|
-
this.countryLayer = new VectorLayer({
|
|
231
|
-
source: new VectorSource({
|
|
232
|
-
url: `${this.loadMapa.data}`,
|
|
233
|
-
format: new GeoJSON(),
|
|
234
|
-
}),
|
|
235
|
-
style: function (feature) {
|
|
236
|
-
const textStyle = style.getText();
|
|
237
|
-
if (textStyle) {
|
|
238
|
-
textStyle.setText(feature.get("name"));
|
|
239
|
-
}
|
|
240
|
-
return style;
|
|
241
|
-
},
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
this.heatLayer = new HeatmapLayer({
|
|
245
|
-
source: new VectorSource({
|
|
246
|
-
features: [],
|
|
247
|
-
}),
|
|
248
|
-
visible: false,
|
|
249
|
-
radius: 10,
|
|
250
|
-
blur: 25,
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
try {
|
|
254
|
-
this.pointLayer = this.configurationMap
|
|
255
|
-
? new VectorLayer({
|
|
256
|
-
source: new VectorSource({
|
|
257
|
-
features: [],
|
|
258
|
-
}),
|
|
259
|
-
visible: false,
|
|
260
|
-
style: (feature) => {
|
|
261
|
-
const zIndex: any = 1;
|
|
262
|
-
const iconStyle = new Style({
|
|
263
|
-
image: new Icon({
|
|
264
|
-
// opacity: 1,
|
|
265
|
-
src: this.configurationMap?.iconMarker?.iconUrl,
|
|
266
|
-
color: this.configurationMap.iconMarker?.color,
|
|
267
|
-
scale: this.configurationMap.iconMarker.scale,
|
|
268
|
-
// // img: this.configurationMap.iconMarker.image,
|
|
269
|
-
// width: this.configurationMap?.iconMarker.iconSize[0],
|
|
270
|
-
// height: this.configurationMap?.iconMarker.iconSize[1],
|
|
271
|
-
}),
|
|
272
|
-
zIndex: zIndex,
|
|
273
|
-
});
|
|
274
|
-
return iconStyle;
|
|
275
|
-
},
|
|
276
|
-
})
|
|
277
|
-
: undefined;
|
|
278
|
-
} catch (e) {
|
|
279
|
-
console.log(e);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
this.olMap = new Map({
|
|
283
|
-
controls: defaultControls({ attribution: false })
|
|
284
|
-
.extend([new FullScreen({ tipLabel: "Pantalla completa" })])
|
|
285
|
-
.extend([
|
|
286
|
-
new Attribution({
|
|
287
|
-
collapsible: false,
|
|
288
|
-
}),
|
|
289
|
-
]),
|
|
290
|
-
layers: [
|
|
291
|
-
new TileLayer({
|
|
292
|
-
source: new OSM({ attributions: attributions }),
|
|
293
|
-
}),
|
|
294
|
-
this.countryLayer,
|
|
295
|
-
this.heatLayer,
|
|
296
|
-
this.pointLayer,
|
|
297
|
-
],
|
|
298
|
-
target: this.$refs["map-root"] as any,
|
|
299
|
-
|
|
300
|
-
view: new View({
|
|
301
|
-
center: [0, 0],
|
|
302
|
-
zoom: this.zoom,
|
|
303
|
-
// minZoom: 5,
|
|
304
|
-
// maxZoom: 10,
|
|
305
|
-
}),
|
|
306
|
-
});
|
|
307
|
-
// coordenadas de la ciudad por defecto
|
|
308
|
-
const cord = fromLonLat([this.loadMapa.lng, this.loadMapa.lat]);
|
|
309
|
-
this.olMap.getView().adjustCenter(cord);
|
|
310
|
-
this.fitMap();
|
|
311
|
-
},
|
|
312
|
-
initClick() {
|
|
313
|
-
//init clicker
|
|
314
|
-
const container = document.getElementById("popup");
|
|
315
|
-
const closer: any = document.getElementById("popup-closer");
|
|
316
|
-
this.overlay = new Overlay({
|
|
317
|
-
element: container as any,
|
|
318
|
-
autoPan: true,
|
|
319
|
-
// autoPanAnimation: {
|
|
320
|
-
// duration: 250,
|
|
321
|
-
// },
|
|
322
|
-
});
|
|
323
|
-
this.olMap.addOverlay(this.overlay);
|
|
324
|
-
|
|
325
|
-
closer.onclick = () => this.closeOverlay();
|
|
326
|
-
this.olMap.addEventListener("click", this.onClickListener);
|
|
327
|
-
},
|
|
328
|
-
closeOverlay() {
|
|
329
|
-
const closer: any = document.getElementById("popup-closer");
|
|
330
|
-
this.overlay.setPosition(undefined);
|
|
331
|
-
closer.blur();
|
|
332
|
-
return false;
|
|
333
|
-
},
|
|
334
|
-
async onClickListener(event: any) {
|
|
335
|
-
const content: any = document.getElementById("popup-content");
|
|
336
|
-
const closer: any = document.getElementById("popup-closer");
|
|
337
|
-
|
|
338
|
-
if (this.olMap.hasFeatureAtPixel(event.pixel) === true) {
|
|
339
|
-
const feature = this.olMap.getFeaturesAtPixel(event.pixel)[0];
|
|
340
|
-
const type = feature.getGeometry().getType();
|
|
341
|
-
if (type === "Point") {
|
|
342
|
-
const properties = this.olMap
|
|
343
|
-
.getFeaturesAtPixel(event.pixel)[0]
|
|
344
|
-
.getProperties();
|
|
345
|
-
const coordinate = event.coordinate;
|
|
346
|
-
if (this.abrirCerrarLoader) this.abrirCerrarLoader(true);
|
|
347
|
-
try {
|
|
348
|
-
if (this.abrirCerrarLoader) this.abrirCerrarLoader(false);
|
|
349
|
-
let html = "";
|
|
350
|
-
if (this.onClickMarket) html = await this.onClickMarket(properties);
|
|
351
|
-
content.innerHTML = html;
|
|
352
|
-
//centra el mapa en el punto con el mismo zoom
|
|
353
|
-
const view = this.olMap.getView();
|
|
354
|
-
const extent = feature.getGeometry().getExtent();
|
|
355
|
-
const oldCenter = view.getCenter();
|
|
356
|
-
const oldZoom = view.getZoom();
|
|
357
|
-
view.fit(extent, { padding: [325, 75, 0, 75], maxZoom: oldZoom });
|
|
358
|
-
const newCenter = view.getCenter();
|
|
359
|
-
view.setCenter(oldCenter);
|
|
360
|
-
view.animate({ center: newCenter });
|
|
361
|
-
} catch (e) {
|
|
362
|
-
if (this.abrirCerrarLoader) this.abrirCerrarLoader(false);
|
|
363
|
-
// toastr.warning('Ocurrio un error, consulte con el administrador');
|
|
364
|
-
}
|
|
365
|
-
this.overlay.setPosition(coordinate);
|
|
366
|
-
}
|
|
367
|
-
} else {
|
|
368
|
-
this.overlay.setPosition(undefined);
|
|
369
|
-
closer.blur();
|
|
370
|
-
}
|
|
371
|
-
},
|
|
372
|
-
updateSource(coords: any) {
|
|
373
|
-
if (coords && coords.features.length === 0) {
|
|
374
|
-
const source = this.heatLayer.getSource();
|
|
375
|
-
source.clear();
|
|
376
|
-
return;
|
|
377
|
-
}
|
|
378
|
-
if (coords) {
|
|
379
|
-
const source = this.heatLayer.getSource();
|
|
380
|
-
|
|
381
|
-
const features = new GeoJSON({
|
|
382
|
-
featureProjection: "EPSG:3857",
|
|
383
|
-
}).readFeatures(coords);
|
|
384
|
-
|
|
385
|
-
source.clear();
|
|
386
|
-
source.addFeatures(features);
|
|
387
|
-
}
|
|
388
|
-
},
|
|
389
|
-
updatePointSource(coords: any) {
|
|
390
|
-
if (coords && coords.features.length === 0) {
|
|
391
|
-
const source = this.pointLayer.getSource();
|
|
392
|
-
source.clear();
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
if (coords) {
|
|
396
|
-
const source = this.pointLayer.getSource();
|
|
397
|
-
|
|
398
|
-
const features = new GeoJSON({
|
|
399
|
-
featureProjection: "EPSG:3857",
|
|
400
|
-
}).readFeatures(coords);
|
|
401
|
-
|
|
402
|
-
source.clear();
|
|
403
|
-
source.addFeatures(features);
|
|
404
|
-
}
|
|
405
|
-
},
|
|
406
|
-
async changeCountryLayer(data: any) {
|
|
407
|
-
const source = this.countryLayer;
|
|
408
|
-
if (source) {
|
|
409
|
-
const src = new VectorSource({
|
|
410
|
-
url: `${data.data}`,
|
|
411
|
-
format: new GeoJSON(),
|
|
412
|
-
});
|
|
413
|
-
await this.countryLayer.setSource(src);
|
|
414
|
-
}
|
|
415
|
-
},
|
|
416
|
-
fitMap() {
|
|
417
|
-
// this zooms the view on the created object
|
|
418
|
-
this.countryLayer.addEventListener("change", this.countryFunction);
|
|
419
|
-
},
|
|
420
|
-
countryFunction(evt: any) {
|
|
421
|
-
const view = this.olMap.getView();
|
|
422
|
-
|
|
423
|
-
const feature = evt.target.getSource().getFeatures()[0];
|
|
424
|
-
if (feature) {
|
|
425
|
-
const extent = evt.target.getSource().getExtent();
|
|
426
|
-
const oldZoom = view.getZoom();
|
|
427
|
-
const oldCenter = view.getCenter();
|
|
428
|
-
view.fit(extent, { padding: [75, 75, 75, 75], maxZoom: 6 });
|
|
429
|
-
const newZoom = view.getZoom();
|
|
430
|
-
const newCenter = view.getCenter();
|
|
431
|
-
view.setCenter(oldCenter);
|
|
432
|
-
view.setZoom(oldZoom);
|
|
433
|
-
view.animate({ center: newCenter });
|
|
434
|
-
view.animate({ zoom: newZoom });
|
|
435
|
-
}
|
|
436
|
-
},
|
|
437
|
-
setRadius(radius: any) {
|
|
438
|
-
this.heatLayer.setRadius(parseInt(radius, 10));
|
|
439
|
-
},
|
|
440
|
-
setBlur(blur: any) {
|
|
441
|
-
this.heatLayer.setBlur(parseInt(blur, 10));
|
|
442
|
-
},
|
|
443
|
-
irACiudad() {
|
|
444
|
-
if (this.loadMapa)
|
|
445
|
-
if (this.loadMapa.country !== "Bolivia") {
|
|
446
|
-
const view = this.olMap.getView();
|
|
447
|
-
const oldZoom = view.getZoom();
|
|
448
|
-
const oldCenter = view.getCenter();
|
|
449
|
-
view.setCenter(fromLonLat([this.loadMapa.lng, this.loadMapa.lat]));
|
|
450
|
-
const newZoom = 13;
|
|
451
|
-
const newCenter = view.getCenter();
|
|
452
|
-
view.setCenter(oldCenter);
|
|
453
|
-
view.setZoom(oldZoom);
|
|
454
|
-
view.animate({ center: newCenter });
|
|
455
|
-
view.animate({ zoom: newZoom });
|
|
456
|
-
}
|
|
457
|
-
},
|
|
458
|
-
toggleSettings() {
|
|
459
|
-
this.showSetting = !this.showSetting;
|
|
460
|
-
},
|
|
461
|
-
},
|
|
462
|
-
mounted() {
|
|
463
|
-
this.countryLayer = this.loadMapa;
|
|
464
|
-
this.initMap();
|
|
465
|
-
},
|
|
466
|
-
beforeDestroy() {
|
|
467
|
-
this.countryLayer.removeEventListener("change", this.countryFunction);
|
|
468
|
-
this.olMap.removeEventListener("click", this.onClickListener);
|
|
469
|
-
},
|
|
470
|
-
});
|
|
471
|
-
</script>
|
|
472
|
-
<style lang="scss" scoped>
|
|
473
|
-
.text-cantidad {
|
|
474
|
-
color: #000 !important;
|
|
475
|
-
margin: 0;
|
|
476
|
-
font-size: 16px;
|
|
477
|
-
padding: 0 1rem;
|
|
478
|
-
}
|
|
479
|
-
.cant-casos {
|
|
480
|
-
position: absolute;
|
|
481
|
-
right: 0;
|
|
482
|
-
bottom: 24px;
|
|
483
|
-
z-index: 10;
|
|
484
|
-
}
|
|
485
|
-
.map-container {
|
|
486
|
-
flex: 1;
|
|
487
|
-
}
|
|
488
|
-
@media only screen and (max-width: 600px) {
|
|
489
|
-
.map-container {
|
|
490
|
-
flex: none;
|
|
491
|
-
height: 65%;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
.btn-settings {
|
|
495
|
-
z-index: 10;
|
|
496
|
-
bottom: 0.5em;
|
|
497
|
-
left: 0.5em;
|
|
498
|
-
}
|
|
499
|
-
.btn-icon {
|
|
500
|
-
font-size: 12px;
|
|
501
|
-
}
|
|
502
|
-
.btn-zoom-container {
|
|
503
|
-
z-index: 10;
|
|
504
|
-
top: 4.5em;
|
|
505
|
-
left: 0.5em;
|
|
506
|
-
}
|
|
507
|
-
.type-map-container {
|
|
508
|
-
z-index: 10;
|
|
509
|
-
top: 7em;
|
|
510
|
-
left: 0.5em;
|
|
511
|
-
}
|
|
512
|
-
.control-container {
|
|
513
|
-
color: #fff;
|
|
514
|
-
position: absolute;
|
|
515
|
-
bottom: 0;
|
|
516
|
-
z-index: 1;
|
|
517
|
-
left: 0;
|
|
518
|
-
background: rgba(0, 0, 0, 0.4);
|
|
519
|
-
padding: 16px;
|
|
520
|
-
& .map-flex {
|
|
521
|
-
display: flex;
|
|
522
|
-
flex-direction: column;
|
|
523
|
-
& label {
|
|
524
|
-
font-family: Roboto;
|
|
525
|
-
font-weight: 600;
|
|
526
|
-
font-size: 12px;
|
|
527
|
-
}
|
|
528
|
-
& input[type="range"] {
|
|
529
|
-
accent-color: var(--primary-light-color, #f28b0c);
|
|
530
|
-
// color: red;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
</style>
|
|
535
|
-
|
|
536
|
-
<style lang="scss">
|
|
537
|
-
button.jl2-button-map {
|
|
538
|
-
background-color: var(--primary-color, #f29512);
|
|
539
|
-
/* padding: 1rem; */
|
|
540
|
-
& svg {
|
|
541
|
-
width: 12px;
|
|
542
|
-
height: 12px;
|
|
543
|
-
fill: white;
|
|
544
|
-
}
|
|
545
|
-
&:hover {
|
|
546
|
-
background: #f28b0c;
|
|
547
|
-
border: none !important;
|
|
548
|
-
outline: none;
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
button.jl2-button-map-select {
|
|
552
|
-
// border: 1px solid #4e5358;
|
|
553
|
-
& svg {
|
|
554
|
-
fill: #4e5358;
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
.ol-control button {
|
|
559
|
-
color: white;
|
|
560
|
-
background-color: var(--primary-color, #f29512);
|
|
561
|
-
}
|
|
562
|
-
.ol-control button:focus,
|
|
563
|
-
.ol-control button:hover {
|
|
564
|
-
// background-color: var(--pssrimary-color, #f28b0c);
|
|
565
|
-
background-color: var(--primary-light-color, #f28b0c);
|
|
566
|
-
cursor: pointer;
|
|
567
|
-
border: none !important;
|
|
568
|
-
outline: none;
|
|
569
|
-
color: white;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
.align-img {
|
|
573
|
-
text-align: center;
|
|
574
|
-
// height: 10px;
|
|
575
|
-
// width: 10px;
|
|
576
|
-
}
|
|
577
|
-
.rotate-north {
|
|
578
|
-
top: 65px;
|
|
579
|
-
left: 0.5em;
|
|
580
|
-
}
|
|
581
|
-
.ol-touch .rotate-north {
|
|
582
|
-
top: 80px;
|
|
583
|
-
}
|
|
584
|
-
.ol-popup {
|
|
585
|
-
font-size: 12px;
|
|
586
|
-
position: absolute;
|
|
587
|
-
background-color: white;
|
|
588
|
-
-webkit-filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
|
|
589
|
-
filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
|
|
590
|
-
padding: 0px 10px 0px 10px;
|
|
591
|
-
border-radius: 10px;
|
|
592
|
-
border: 1px solid #cccccc;
|
|
593
|
-
bottom: 12px;
|
|
594
|
-
left: -50px;
|
|
595
|
-
min-width: 190px;
|
|
596
|
-
font-family: "Roboto";
|
|
597
|
-
& .ol-title {
|
|
598
|
-
letter-spacing: 1px;
|
|
599
|
-
font-size: 14px;
|
|
600
|
-
font-weight: 700;
|
|
601
|
-
margin-bottom: 5px;
|
|
602
|
-
text-align: center;
|
|
603
|
-
color: #4e5358 !important;
|
|
604
|
-
}
|
|
605
|
-
& .ol-bold {
|
|
606
|
-
font-weight: 600;
|
|
607
|
-
}
|
|
608
|
-
& .ol-text {
|
|
609
|
-
font-weight: 300;
|
|
610
|
-
color: #4e5358 !important;
|
|
611
|
-
margin: 0px;
|
|
612
|
-
margin-top: 6px;
|
|
613
|
-
margin-bottom: 6px;
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
.ol-popup:after,
|
|
618
|
-
.ol-popup:before {
|
|
619
|
-
top: 100%;
|
|
620
|
-
border: solid transparent;
|
|
621
|
-
content: " ";
|
|
622
|
-
height: 0;
|
|
623
|
-
width: 0;
|
|
624
|
-
position: absolute;
|
|
625
|
-
pointer-events: none;
|
|
626
|
-
}
|
|
627
|
-
.ol-popup:after {
|
|
628
|
-
border-top-color: white;
|
|
629
|
-
border-width: 10px;
|
|
630
|
-
left: 48px;
|
|
631
|
-
margin-left: -10px;
|
|
632
|
-
}
|
|
633
|
-
.ol-popup:before {
|
|
634
|
-
border-top-color: #cccccc;
|
|
635
|
-
border-width: 11px;
|
|
636
|
-
left: 48px;
|
|
637
|
-
margin-left: -11px;
|
|
638
|
-
}
|
|
639
|
-
.ol-popup-closer {
|
|
640
|
-
text-decoration: none;
|
|
641
|
-
position: absolute;
|
|
642
|
-
top: -8px;
|
|
643
|
-
right: -8px;
|
|
644
|
-
padding: 3px 4px;
|
|
645
|
-
border-radius: 1rem;
|
|
646
|
-
background-color: var(--primary-color, #f29512);
|
|
647
|
-
}
|
|
648
|
-
.ol-popup-closer:after {
|
|
649
|
-
display: flex;
|
|
650
|
-
align-content: center;
|
|
651
|
-
font-size: 12px;
|
|
652
|
-
content: "✖";
|
|
653
|
-
color: white;
|
|
654
|
-
}
|
|
655
|
-
.ol-popup-closer:hover::after {
|
|
656
|
-
content: "✖";
|
|
657
|
-
background-color: var(--primary-light-color, #f28b0c);
|
|
658
|
-
}
|
|
659
|
-
.map-copyright-text {
|
|
660
|
-
font-size: 12px;
|
|
661
|
-
font-weight: 600px;
|
|
662
|
-
// font-family: Roboto;
|
|
663
|
-
}
|
|
664
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="map-container" :style="`height:${configurationMap?.height}`">
|
|
3
|
+
<div ref="map-root" style="width: 100%; height: 100%; position: relative">
|
|
4
|
+
<div
|
|
5
|
+
v-show="loadMapa.country !== 'Bolivia'"
|
|
6
|
+
class="btn-zoom-container ol-control"
|
|
7
|
+
>
|
|
8
|
+
<button
|
|
9
|
+
title="Ir a la ciudad"
|
|
10
|
+
class="jl2-button-map"
|
|
11
|
+
@click="irACiudad"
|
|
12
|
+
>
|
|
13
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
|
14
|
+
<path
|
|
15
|
+
d="M278.6 9.4c-12.5-12.5-32.8-12.5-45.3 0l-64 64c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l9.4-9.4V224H109.3l9.4-9.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-64 64c-12.5 12.5-12.5 32.8 0 45.3l64 64c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-9.4-9.4H224v114.8l-9.4-9.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l64 64c12.5 12.5 32.8 12.5 45.3 0l64-64c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-9.4 9.4V288h114.8l-9.4 9.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l64-64c12.5-12.5 12.5-32.8 0-45.3l-64-64c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l9.4 9.4H288V109.3l9.4 9.4c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-64-64z"
|
|
16
|
+
/>
|
|
17
|
+
</svg>
|
|
18
|
+
</button>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<div class="type-map-container ol-control">
|
|
22
|
+
<!-- button para mapa con marcadores -->
|
|
23
|
+
<button
|
|
24
|
+
title="Mapa con Marcador"
|
|
25
|
+
class="jl2-button-map"
|
|
26
|
+
:class="{ 'jl2-button-map-select': type == '1' }"
|
|
27
|
+
@click="() => (type = '1')"
|
|
28
|
+
>
|
|
29
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512">
|
|
30
|
+
<path
|
|
31
|
+
d="M215.7 499.2C267 435 384 279.4 384 192 384 86 298 0 192 0S0 86 0 192c0 87.4 117 243 168.3 307.2 12.3 15.3 35.1 15.3 47.4 0zM192 128a64 64 0 1 1 0 128 64 64 0 1 1 0-128z"
|
|
32
|
+
/>
|
|
33
|
+
</svg>
|
|
34
|
+
</button>
|
|
35
|
+
<!-- button para mapa de calor -->
|
|
36
|
+
<button
|
|
37
|
+
title="Mapa de Calor"
|
|
38
|
+
class="jl2-button-map"
|
|
39
|
+
:class="{ 'jl2-button-map-select': type == '0' }"
|
|
40
|
+
@click="() => (type = '0')"
|
|
41
|
+
>
|
|
42
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512">
|
|
43
|
+
<path
|
|
44
|
+
d="m153.6 29.9 16-21.3c4-5.4 10.4-8.6 17.1-8.6C198.4 0 208 9.6 208 21.3v22.2c0 13.1 5.4 25.7 14.9 34.7l84.7 80.8c48.8 46.6 76.4 111.2 76.4 178.7C384 434 306 512 209.7 512H192C86 512 0 426 0 320v-3.8c0-48.8 19.4-95.6 53.9-130.1l3.5-3.5c4.2-4.2 10-6.6 16-6.6 12.5 0 22.6 10.1 22.6 22.6V288c0 35.3 28.7 64 64 64s64-28.7 64-64v-3.9c0-18-7.2-35.3-19.9-48l-38.6-38.6c-24-24-37.5-56.7-37.5-90.7 0-27.7 9-54.8 25.6-76.9z"
|
|
45
|
+
/>
|
|
46
|
+
</svg>
|
|
47
|
+
</button>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<!-- Botón de configuraciones -->
|
|
51
|
+
<div
|
|
52
|
+
class="btn-settings ol-control"
|
|
53
|
+
v-show="!showSetting && type === '0'"
|
|
54
|
+
>
|
|
55
|
+
<button
|
|
56
|
+
title="Ver Opciones"
|
|
57
|
+
class="jl2-button-map"
|
|
58
|
+
@click="toggleSettings"
|
|
59
|
+
>
|
|
60
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
|
61
|
+
<path
|
|
62
|
+
d="M495.9 166.6c3.2 8.7.5 18.4-6.4 24.6l-43.3 39.4c1.1 8.3 1.7 16.8 1.7 25.4s-.6 17.1-1.7 25.4l43.3 39.4c6.9 6.2 9.6 15.9 6.4 24.6-4.4 11.9-9.7 23.3-15.8 34.3l-4.7 8.1c-6.6 11-14 21.4-22.1 31.2-5.9 7.2-15.7 9.6-24.5 6.8l-55.7-17.7c-13.4 10.3-28.2 18.9-44 25.4l-12.5 57.1c-2 9.1-9 16.3-18.2 17.8-13.8 2.3-28 3.5-42.5 3.5s-28.7-1.2-42.5-3.5c-9.2-1.5-16.2-8.7-18.2-17.8l-12.5-57.1c-15.8-6.5-30.6-15.1-44-25.4l-55.6 17.8c-8.8 2.8-18.6.3-24.5-6.8-8.1-9.8-15.5-20.2-22.1-31.2l-4.7-8.1c-6.1-11-11.4-22.4-15.8-34.3-3.2-8.7-.5-18.4 6.4-24.6l43.3-39.4c-1.1-8.4-1.7-16.9-1.7-25.5s.6-17.1 1.7-25.4l-43.3-39.4c-6.9-6.2-9.6-15.9-6.4-24.6 4.4-11.9 9.7-23.3 15.8-34.3l4.7-8.1c6.6-11 14-21.4 22.1-31.2 5.9-7.2 15.7-9.6 24.5-6.8l55.7 17.7c13.4-10.3 28.2-18.9 44-25.4l12.5-57.1c2-9.1 9-16.3 18.2-17.8C227.3 1.2 241.5 0 256 0s28.7 1.2 42.5 3.5c9.2 1.5 16.2 8.7 18.2 17.8l12.5 57.1c15.8 6.5 30.6 15.1 44 25.4l55.7-17.7c8.8-2.8 18.6-.3 24.5 6.8 8.1 9.8 15.5 20.2 22.1 31.2l4.7 8.1c6.1 11 11.4 22.4 15.8 34.3zM256 336a80 80 0 1 0 0-160 80 80 0 1 0 0 160z"
|
|
63
|
+
/>
|
|
64
|
+
</svg>
|
|
65
|
+
</button>
|
|
66
|
+
</div>
|
|
67
|
+
<!-- Opciones de configuraciones -->
|
|
68
|
+
<div class="control-container" v-show="type === '0' && showSetting">
|
|
69
|
+
<a @click="toggleSettings" class="ol-popup-closer"></a>
|
|
70
|
+
<div class="map-flex">
|
|
71
|
+
<label>Tamaño del radio</label>
|
|
72
|
+
<input
|
|
73
|
+
id="radius"
|
|
74
|
+
type="range"
|
|
75
|
+
min="1"
|
|
76
|
+
max="50"
|
|
77
|
+
step="1"
|
|
78
|
+
v-model="radius"
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
<div class="map-flex">
|
|
82
|
+
<label>Difuminado</label>
|
|
83
|
+
<input
|
|
84
|
+
id="blur"
|
|
85
|
+
type="range"
|
|
86
|
+
min="1"
|
|
87
|
+
max="50"
|
|
88
|
+
step="1"
|
|
89
|
+
v-model="blur"
|
|
90
|
+
/>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
<!-- Tag casos Vinculados -->
|
|
94
|
+
<div
|
|
95
|
+
class="cant-casos ol-attribution ol-unselectable ol-control ol-uncollapsible"
|
|
96
|
+
>
|
|
97
|
+
<p class="text-cantidad">
|
|
98
|
+
<span class="ol-bold">Casos: </span>{{ cantidad }}
|
|
99
|
+
</p>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
<div id="popup" class="ol-popup" v-show="type === '1'">
|
|
103
|
+
<a id="popup-closer" class="ol-popup-closer"></a>
|
|
104
|
+
<div id="popup-content"></div>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
</template>
|
|
108
|
+
|
|
109
|
+
<script lang="ts">
|
|
110
|
+
import "ol/ol.css";
|
|
111
|
+
import View from "ol/View";
|
|
112
|
+
import Map from "ol/Map";
|
|
113
|
+
import HeatmapLayer from "ol/layer/Heatmap";
|
|
114
|
+
import OSM from "ol/source/OSM";
|
|
115
|
+
import TileLayer from "ol/layer/Tile";
|
|
116
|
+
import VectorSource from "ol/source/Vector";
|
|
117
|
+
import GeoJSON from "ol/format/GeoJSON";
|
|
118
|
+
import { fromLonLat } from "ol/proj";
|
|
119
|
+
import Fill from "ol/style/Fill";
|
|
120
|
+
import Stroke from "ol/style/Stroke";
|
|
121
|
+
import Text from "ol/style/Text";
|
|
122
|
+
import VectorLayer from "ol/layer/Vector";
|
|
123
|
+
import Overlay from "ol/Overlay";
|
|
124
|
+
import { Icon, Style } from "ol/style";
|
|
125
|
+
|
|
126
|
+
import {
|
|
127
|
+
Attribution,
|
|
128
|
+
FullScreen,
|
|
129
|
+
defaults as defaultControls,
|
|
130
|
+
} from "ol/control";
|
|
131
|
+
import { defineComponent } from "vue";
|
|
132
|
+
import { markerDefault } from "../helpers/imgBase64";
|
|
133
|
+
|
|
134
|
+
export default defineComponent({
|
|
135
|
+
name: "MapHeat",
|
|
136
|
+
props: {
|
|
137
|
+
coords: Object as any,
|
|
138
|
+
loadMapa: Object as any,
|
|
139
|
+
typeMap: String,
|
|
140
|
+
abrirCerrarLoader: Function,
|
|
141
|
+
onClickMarket: Function,
|
|
142
|
+
configurationMap: {
|
|
143
|
+
default: () => {
|
|
144
|
+
return {
|
|
145
|
+
strokeColor: "#f47521",
|
|
146
|
+
copyright: "© 2021 Desarrollado por UTIC - Ministerio Público",
|
|
147
|
+
height: "250px",
|
|
148
|
+
maxZoom: 20,
|
|
149
|
+
iconMarker: {
|
|
150
|
+
image: markerDefault,
|
|
151
|
+
color: "#f47521",
|
|
152
|
+
iconUrl: "/image/gmap01.png",
|
|
153
|
+
iconSize: [25, 41],
|
|
154
|
+
iconAnchor: [12, 41],
|
|
155
|
+
scale: 1,
|
|
156
|
+
class: "",
|
|
157
|
+
type: "image",
|
|
158
|
+
},
|
|
159
|
+
dragMarker: true,
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
data: () => ({
|
|
165
|
+
// store OL objects on the component instance
|
|
166
|
+
radius: 10,
|
|
167
|
+
blur: 20,
|
|
168
|
+
zoom: 5,
|
|
169
|
+
type: "0",
|
|
170
|
+
olMap: null as any,
|
|
171
|
+
heatLayer: null as any,
|
|
172
|
+
pointLayer: null as any,
|
|
173
|
+
countryLayer: null as any,
|
|
174
|
+
overlay: null as any,
|
|
175
|
+
showSetting: false,
|
|
176
|
+
cantidad: 0,
|
|
177
|
+
}),
|
|
178
|
+
watch: {
|
|
179
|
+
radius(value) {
|
|
180
|
+
this.setRadius(value);
|
|
181
|
+
},
|
|
182
|
+
blur(value) {
|
|
183
|
+
this.setBlur(value);
|
|
184
|
+
},
|
|
185
|
+
coords(value) {
|
|
186
|
+
this.cantidad = value.features.length;
|
|
187
|
+
this.updateSource(value);
|
|
188
|
+
this.updatePointSource(value);
|
|
189
|
+
},
|
|
190
|
+
loadMapa(val) {
|
|
191
|
+
this.changeCountryLayer(val);
|
|
192
|
+
},
|
|
193
|
+
typeMap(val) {
|
|
194
|
+
this.changeTypeMap(val);
|
|
195
|
+
},
|
|
196
|
+
type(type) {
|
|
197
|
+
this.changeTypeMap(type);
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
methods: {
|
|
201
|
+
changeTypeMap(type: string) {
|
|
202
|
+
if (type === "0") {
|
|
203
|
+
this.heatLayer.setVisible(true);
|
|
204
|
+
this.pointLayer.setVisible(false);
|
|
205
|
+
this.olMap.removeEventListener("click", this.onClickListener);
|
|
206
|
+
} else {
|
|
207
|
+
this.heatLayer.setVisible(false);
|
|
208
|
+
this.pointLayer.setVisible(true);
|
|
209
|
+
this.initClick();
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
initMap() {
|
|
213
|
+
const attributions = `<span class='map-copyright-text' >${this.configurationMap.copyright}</span>`;
|
|
214
|
+
const style = new Style({
|
|
215
|
+
stroke: new Stroke({
|
|
216
|
+
color: this.configurationMap.strokeColor,
|
|
217
|
+
width: 3,
|
|
218
|
+
}),
|
|
219
|
+
text: new Text({
|
|
220
|
+
font: "12px Roboto",
|
|
221
|
+
fill: new Fill({
|
|
222
|
+
color: "#000",
|
|
223
|
+
}),
|
|
224
|
+
stroke: new Stroke({
|
|
225
|
+
color: "#fff",
|
|
226
|
+
width: 1,
|
|
227
|
+
}),
|
|
228
|
+
}),
|
|
229
|
+
});
|
|
230
|
+
this.countryLayer = new VectorLayer({
|
|
231
|
+
source: new VectorSource({
|
|
232
|
+
url: `${this.loadMapa.data}`,
|
|
233
|
+
format: new GeoJSON(),
|
|
234
|
+
}),
|
|
235
|
+
style: function (feature) {
|
|
236
|
+
const textStyle = style.getText();
|
|
237
|
+
if (textStyle) {
|
|
238
|
+
textStyle.setText(feature.get("name"));
|
|
239
|
+
}
|
|
240
|
+
return style;
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
this.heatLayer = new HeatmapLayer({
|
|
245
|
+
source: new VectorSource({
|
|
246
|
+
features: [],
|
|
247
|
+
}),
|
|
248
|
+
visible: false,
|
|
249
|
+
radius: 10,
|
|
250
|
+
blur: 25,
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
try {
|
|
254
|
+
this.pointLayer = this.configurationMap
|
|
255
|
+
? new VectorLayer({
|
|
256
|
+
source: new VectorSource({
|
|
257
|
+
features: [],
|
|
258
|
+
}),
|
|
259
|
+
visible: false,
|
|
260
|
+
style: (feature) => {
|
|
261
|
+
const zIndex: any = 1;
|
|
262
|
+
const iconStyle = new Style({
|
|
263
|
+
image: new Icon({
|
|
264
|
+
// opacity: 1,
|
|
265
|
+
src: this.configurationMap?.iconMarker?.iconUrl,
|
|
266
|
+
color: this.configurationMap.iconMarker?.color,
|
|
267
|
+
scale: this.configurationMap.iconMarker.scale,
|
|
268
|
+
// // img: this.configurationMap.iconMarker.image,
|
|
269
|
+
// width: this.configurationMap?.iconMarker.iconSize[0],
|
|
270
|
+
// height: this.configurationMap?.iconMarker.iconSize[1],
|
|
271
|
+
}),
|
|
272
|
+
zIndex: zIndex,
|
|
273
|
+
});
|
|
274
|
+
return iconStyle;
|
|
275
|
+
},
|
|
276
|
+
})
|
|
277
|
+
: undefined;
|
|
278
|
+
} catch (e) {
|
|
279
|
+
console.log(e);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
this.olMap = new Map({
|
|
283
|
+
controls: defaultControls({ attribution: false })
|
|
284
|
+
.extend([new FullScreen({ tipLabel: "Pantalla completa" })])
|
|
285
|
+
.extend([
|
|
286
|
+
new Attribution({
|
|
287
|
+
collapsible: false,
|
|
288
|
+
}),
|
|
289
|
+
]),
|
|
290
|
+
layers: [
|
|
291
|
+
new TileLayer({
|
|
292
|
+
source: new OSM({ attributions: attributions }),
|
|
293
|
+
}),
|
|
294
|
+
this.countryLayer,
|
|
295
|
+
this.heatLayer,
|
|
296
|
+
this.pointLayer,
|
|
297
|
+
],
|
|
298
|
+
target: this.$refs["map-root"] as any,
|
|
299
|
+
|
|
300
|
+
view: new View({
|
|
301
|
+
center: [0, 0],
|
|
302
|
+
zoom: this.zoom,
|
|
303
|
+
// minZoom: 5,
|
|
304
|
+
// maxZoom: 10,
|
|
305
|
+
}),
|
|
306
|
+
});
|
|
307
|
+
// coordenadas de la ciudad por defecto
|
|
308
|
+
const cord = fromLonLat([this.loadMapa.lng, this.loadMapa.lat]);
|
|
309
|
+
this.olMap.getView().adjustCenter(cord);
|
|
310
|
+
this.fitMap();
|
|
311
|
+
},
|
|
312
|
+
initClick() {
|
|
313
|
+
//init clicker
|
|
314
|
+
const container = document.getElementById("popup");
|
|
315
|
+
const closer: any = document.getElementById("popup-closer");
|
|
316
|
+
this.overlay = new Overlay({
|
|
317
|
+
element: container as any,
|
|
318
|
+
autoPan: true,
|
|
319
|
+
// autoPanAnimation: {
|
|
320
|
+
// duration: 250,
|
|
321
|
+
// },
|
|
322
|
+
});
|
|
323
|
+
this.olMap.addOverlay(this.overlay);
|
|
324
|
+
|
|
325
|
+
closer.onclick = () => this.closeOverlay();
|
|
326
|
+
this.olMap.addEventListener("click", this.onClickListener);
|
|
327
|
+
},
|
|
328
|
+
closeOverlay() {
|
|
329
|
+
const closer: any = document.getElementById("popup-closer");
|
|
330
|
+
this.overlay.setPosition(undefined);
|
|
331
|
+
closer.blur();
|
|
332
|
+
return false;
|
|
333
|
+
},
|
|
334
|
+
async onClickListener(event: any) {
|
|
335
|
+
const content: any = document.getElementById("popup-content");
|
|
336
|
+
const closer: any = document.getElementById("popup-closer");
|
|
337
|
+
|
|
338
|
+
if (this.olMap.hasFeatureAtPixel(event.pixel) === true) {
|
|
339
|
+
const feature = this.olMap.getFeaturesAtPixel(event.pixel)[0];
|
|
340
|
+
const type = feature.getGeometry().getType();
|
|
341
|
+
if (type === "Point") {
|
|
342
|
+
const properties = this.olMap
|
|
343
|
+
.getFeaturesAtPixel(event.pixel)[0]
|
|
344
|
+
.getProperties();
|
|
345
|
+
const coordinate = event.coordinate;
|
|
346
|
+
if (this.abrirCerrarLoader) this.abrirCerrarLoader(true);
|
|
347
|
+
try {
|
|
348
|
+
if (this.abrirCerrarLoader) this.abrirCerrarLoader(false);
|
|
349
|
+
let html = "";
|
|
350
|
+
if (this.onClickMarket) html = await this.onClickMarket(properties);
|
|
351
|
+
content.innerHTML = html;
|
|
352
|
+
//centra el mapa en el punto con el mismo zoom
|
|
353
|
+
const view = this.olMap.getView();
|
|
354
|
+
const extent = feature.getGeometry().getExtent();
|
|
355
|
+
const oldCenter = view.getCenter();
|
|
356
|
+
const oldZoom = view.getZoom();
|
|
357
|
+
view.fit(extent, { padding: [325, 75, 0, 75], maxZoom: oldZoom });
|
|
358
|
+
const newCenter = view.getCenter();
|
|
359
|
+
view.setCenter(oldCenter);
|
|
360
|
+
view.animate({ center: newCenter });
|
|
361
|
+
} catch (e) {
|
|
362
|
+
if (this.abrirCerrarLoader) this.abrirCerrarLoader(false);
|
|
363
|
+
// toastr.warning('Ocurrio un error, consulte con el administrador');
|
|
364
|
+
}
|
|
365
|
+
this.overlay.setPosition(coordinate);
|
|
366
|
+
}
|
|
367
|
+
} else {
|
|
368
|
+
this.overlay.setPosition(undefined);
|
|
369
|
+
closer.blur();
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
updateSource(coords: any) {
|
|
373
|
+
if (coords && coords.features.length === 0) {
|
|
374
|
+
const source = this.heatLayer.getSource();
|
|
375
|
+
source.clear();
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (coords) {
|
|
379
|
+
const source = this.heatLayer.getSource();
|
|
380
|
+
|
|
381
|
+
const features = new GeoJSON({
|
|
382
|
+
featureProjection: "EPSG:3857",
|
|
383
|
+
}).readFeatures(coords);
|
|
384
|
+
|
|
385
|
+
source.clear();
|
|
386
|
+
source.addFeatures(features);
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
updatePointSource(coords: any) {
|
|
390
|
+
if (coords && coords.features.length === 0) {
|
|
391
|
+
const source = this.pointLayer.getSource();
|
|
392
|
+
source.clear();
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
if (coords) {
|
|
396
|
+
const source = this.pointLayer.getSource();
|
|
397
|
+
|
|
398
|
+
const features = new GeoJSON({
|
|
399
|
+
featureProjection: "EPSG:3857",
|
|
400
|
+
}).readFeatures(coords);
|
|
401
|
+
|
|
402
|
+
source.clear();
|
|
403
|
+
source.addFeatures(features);
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
async changeCountryLayer(data: any) {
|
|
407
|
+
const source = this.countryLayer;
|
|
408
|
+
if (source) {
|
|
409
|
+
const src = new VectorSource({
|
|
410
|
+
url: `${data.data}`,
|
|
411
|
+
format: new GeoJSON(),
|
|
412
|
+
});
|
|
413
|
+
await this.countryLayer.setSource(src);
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
fitMap() {
|
|
417
|
+
// this zooms the view on the created object
|
|
418
|
+
this.countryLayer.addEventListener("change", this.countryFunction);
|
|
419
|
+
},
|
|
420
|
+
countryFunction(evt: any) {
|
|
421
|
+
const view = this.olMap.getView();
|
|
422
|
+
|
|
423
|
+
const feature = evt.target.getSource().getFeatures()[0];
|
|
424
|
+
if (feature) {
|
|
425
|
+
const extent = evt.target.getSource().getExtent();
|
|
426
|
+
const oldZoom = view.getZoom();
|
|
427
|
+
const oldCenter = view.getCenter();
|
|
428
|
+
view.fit(extent, { padding: [75, 75, 75, 75], maxZoom: 6 });
|
|
429
|
+
const newZoom = view.getZoom();
|
|
430
|
+
const newCenter = view.getCenter();
|
|
431
|
+
view.setCenter(oldCenter);
|
|
432
|
+
view.setZoom(oldZoom);
|
|
433
|
+
view.animate({ center: newCenter });
|
|
434
|
+
view.animate({ zoom: newZoom });
|
|
435
|
+
}
|
|
436
|
+
},
|
|
437
|
+
setRadius(radius: any) {
|
|
438
|
+
this.heatLayer.setRadius(parseInt(radius, 10));
|
|
439
|
+
},
|
|
440
|
+
setBlur(blur: any) {
|
|
441
|
+
this.heatLayer.setBlur(parseInt(blur, 10));
|
|
442
|
+
},
|
|
443
|
+
irACiudad() {
|
|
444
|
+
if (this.loadMapa)
|
|
445
|
+
if (this.loadMapa.country !== "Bolivia") {
|
|
446
|
+
const view = this.olMap.getView();
|
|
447
|
+
const oldZoom = view.getZoom();
|
|
448
|
+
const oldCenter = view.getCenter();
|
|
449
|
+
view.setCenter(fromLonLat([this.loadMapa.lng, this.loadMapa.lat]));
|
|
450
|
+
const newZoom = 13;
|
|
451
|
+
const newCenter = view.getCenter();
|
|
452
|
+
view.setCenter(oldCenter);
|
|
453
|
+
view.setZoom(oldZoom);
|
|
454
|
+
view.animate({ center: newCenter });
|
|
455
|
+
view.animate({ zoom: newZoom });
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
toggleSettings() {
|
|
459
|
+
this.showSetting = !this.showSetting;
|
|
460
|
+
},
|
|
461
|
+
},
|
|
462
|
+
mounted() {
|
|
463
|
+
this.countryLayer = this.loadMapa;
|
|
464
|
+
this.initMap();
|
|
465
|
+
},
|
|
466
|
+
beforeDestroy() {
|
|
467
|
+
this.countryLayer.removeEventListener("change", this.countryFunction);
|
|
468
|
+
this.olMap.removeEventListener("click", this.onClickListener);
|
|
469
|
+
},
|
|
470
|
+
});
|
|
471
|
+
</script>
|
|
472
|
+
<style lang="scss" scoped>
|
|
473
|
+
.text-cantidad {
|
|
474
|
+
color: #000 !important;
|
|
475
|
+
margin: 0;
|
|
476
|
+
font-size: 16px;
|
|
477
|
+
padding: 0 1rem;
|
|
478
|
+
}
|
|
479
|
+
.cant-casos {
|
|
480
|
+
position: absolute;
|
|
481
|
+
right: 0;
|
|
482
|
+
bottom: 24px;
|
|
483
|
+
z-index: 10;
|
|
484
|
+
}
|
|
485
|
+
.map-container {
|
|
486
|
+
flex: 1;
|
|
487
|
+
}
|
|
488
|
+
@media only screen and (max-width: 600px) {
|
|
489
|
+
.map-container {
|
|
490
|
+
flex: none;
|
|
491
|
+
height: 65%;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
.btn-settings {
|
|
495
|
+
z-index: 10;
|
|
496
|
+
bottom: 0.5em;
|
|
497
|
+
left: 0.5em;
|
|
498
|
+
}
|
|
499
|
+
.btn-icon {
|
|
500
|
+
font-size: 12px;
|
|
501
|
+
}
|
|
502
|
+
.btn-zoom-container {
|
|
503
|
+
z-index: 10;
|
|
504
|
+
top: 4.5em;
|
|
505
|
+
left: 0.5em;
|
|
506
|
+
}
|
|
507
|
+
.type-map-container {
|
|
508
|
+
z-index: 10;
|
|
509
|
+
top: 7em;
|
|
510
|
+
left: 0.5em;
|
|
511
|
+
}
|
|
512
|
+
.control-container {
|
|
513
|
+
color: #fff;
|
|
514
|
+
position: absolute;
|
|
515
|
+
bottom: 0;
|
|
516
|
+
z-index: 1;
|
|
517
|
+
left: 0;
|
|
518
|
+
background: rgba(0, 0, 0, 0.4);
|
|
519
|
+
padding: 16px;
|
|
520
|
+
& .map-flex {
|
|
521
|
+
display: flex;
|
|
522
|
+
flex-direction: column;
|
|
523
|
+
& label {
|
|
524
|
+
font-family: Roboto;
|
|
525
|
+
font-weight: 600;
|
|
526
|
+
font-size: 12px;
|
|
527
|
+
}
|
|
528
|
+
& input[type="range"] {
|
|
529
|
+
accent-color: var(--primary-light-color, #f28b0c);
|
|
530
|
+
// color: red;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
</style>
|
|
535
|
+
|
|
536
|
+
<style lang="scss">
|
|
537
|
+
button.jl2-button-map {
|
|
538
|
+
background-color: var(--primary-color, #f29512);
|
|
539
|
+
/* padding: 1rem; */
|
|
540
|
+
& svg {
|
|
541
|
+
width: 12px;
|
|
542
|
+
height: 12px;
|
|
543
|
+
fill: white;
|
|
544
|
+
}
|
|
545
|
+
&:hover {
|
|
546
|
+
background: #f28b0c;
|
|
547
|
+
border: none !important;
|
|
548
|
+
outline: none;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
button.jl2-button-map-select {
|
|
552
|
+
// border: 1px solid #4e5358;
|
|
553
|
+
& svg {
|
|
554
|
+
fill: #4e5358;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
.ol-control button {
|
|
559
|
+
color: white;
|
|
560
|
+
background-color: var(--primary-color, #f29512);
|
|
561
|
+
}
|
|
562
|
+
.ol-control button:focus,
|
|
563
|
+
.ol-control button:hover {
|
|
564
|
+
// background-color: var(--pssrimary-color, #f28b0c);
|
|
565
|
+
background-color: var(--primary-light-color, #f28b0c);
|
|
566
|
+
cursor: pointer;
|
|
567
|
+
border: none !important;
|
|
568
|
+
outline: none;
|
|
569
|
+
color: white;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
.align-img {
|
|
573
|
+
text-align: center;
|
|
574
|
+
// height: 10px;
|
|
575
|
+
// width: 10px;
|
|
576
|
+
}
|
|
577
|
+
.rotate-north {
|
|
578
|
+
top: 65px;
|
|
579
|
+
left: 0.5em;
|
|
580
|
+
}
|
|
581
|
+
.ol-touch .rotate-north {
|
|
582
|
+
top: 80px;
|
|
583
|
+
}
|
|
584
|
+
.ol-popup {
|
|
585
|
+
font-size: 12px;
|
|
586
|
+
position: absolute;
|
|
587
|
+
background-color: white;
|
|
588
|
+
-webkit-filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
|
|
589
|
+
filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
|
|
590
|
+
padding: 0px 10px 0px 10px;
|
|
591
|
+
border-radius: 10px;
|
|
592
|
+
border: 1px solid #cccccc;
|
|
593
|
+
bottom: 12px;
|
|
594
|
+
left: -50px;
|
|
595
|
+
min-width: 190px;
|
|
596
|
+
font-family: "Roboto";
|
|
597
|
+
& .ol-title {
|
|
598
|
+
letter-spacing: 1px;
|
|
599
|
+
font-size: 14px;
|
|
600
|
+
font-weight: 700;
|
|
601
|
+
margin-bottom: 5px;
|
|
602
|
+
text-align: center;
|
|
603
|
+
color: #4e5358 !important;
|
|
604
|
+
}
|
|
605
|
+
& .ol-bold {
|
|
606
|
+
font-weight: 600;
|
|
607
|
+
}
|
|
608
|
+
& .ol-text {
|
|
609
|
+
font-weight: 300;
|
|
610
|
+
color: #4e5358 !important;
|
|
611
|
+
margin: 0px;
|
|
612
|
+
margin-top: 6px;
|
|
613
|
+
margin-bottom: 6px;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
.ol-popup:after,
|
|
618
|
+
.ol-popup:before {
|
|
619
|
+
top: 100%;
|
|
620
|
+
border: solid transparent;
|
|
621
|
+
content: " ";
|
|
622
|
+
height: 0;
|
|
623
|
+
width: 0;
|
|
624
|
+
position: absolute;
|
|
625
|
+
pointer-events: none;
|
|
626
|
+
}
|
|
627
|
+
.ol-popup:after {
|
|
628
|
+
border-top-color: white;
|
|
629
|
+
border-width: 10px;
|
|
630
|
+
left: 48px;
|
|
631
|
+
margin-left: -10px;
|
|
632
|
+
}
|
|
633
|
+
.ol-popup:before {
|
|
634
|
+
border-top-color: #cccccc;
|
|
635
|
+
border-width: 11px;
|
|
636
|
+
left: 48px;
|
|
637
|
+
margin-left: -11px;
|
|
638
|
+
}
|
|
639
|
+
.ol-popup-closer {
|
|
640
|
+
text-decoration: none;
|
|
641
|
+
position: absolute;
|
|
642
|
+
top: -8px;
|
|
643
|
+
right: -8px;
|
|
644
|
+
padding: 3px 4px;
|
|
645
|
+
border-radius: 1rem;
|
|
646
|
+
background-color: var(--primary-color, #f29512);
|
|
647
|
+
}
|
|
648
|
+
.ol-popup-closer:after {
|
|
649
|
+
display: flex;
|
|
650
|
+
align-content: center;
|
|
651
|
+
font-size: 12px;
|
|
652
|
+
content: "✖";
|
|
653
|
+
color: white;
|
|
654
|
+
}
|
|
655
|
+
.ol-popup-closer:hover::after {
|
|
656
|
+
content: "✖";
|
|
657
|
+
background-color: var(--primary-light-color, #f28b0c);
|
|
658
|
+
}
|
|
659
|
+
.map-copyright-text {
|
|
660
|
+
font-size: 12px;
|
|
661
|
+
font-weight: 600px;
|
|
662
|
+
// font-family: Roboto;
|
|
663
|
+
}
|
|
664
|
+
</style>
|