vue-geojson-view-ts 1.3.2 → 1.3.3

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.
@@ -1,217 +1,653 @@
1
1
  <template>
2
2
  <div class="map-container" :style="`height:${configurationMap?.height}`">
3
- <div :id="idMap" style="height: 100%"></div>
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>
4
106
  </div>
5
107
  </template>
6
108
 
7
- <script setup lang="ts">
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";
8
125
  import * as L from "leaflet";
9
- import "leaflet/dist/leaflet.css";
10
- import { onMounted, ref } from "vue";
11
- import { markerDefault } from "../helpers/imgBase64";
12
- import "leaflet.fullscreen/Control.FullScreen.css";
13
- import "leaflet.fullscreen";
14
- import "leaflet.heat";
15
-
16
- export type TIconMaker = {
17
- iconUrl: string;
18
- iconSize: [number, number];
19
- iconAnchor: [number, number];
20
- class?: string;
21
- type: "image" | "svg";
22
- };
23
-
24
- export interface IConfigurationMap {
25
- height: string;
26
- maxZoom: number;
27
- iconMarker: TIconMaker;
28
- dragMarker: boolean;
29
- }
30
-
31
- export interface ICoords {
32
- lat: number;
33
- lng: number;
34
- zoom: number;
35
- }
36
-
37
- export interface IHeat {
38
- lat: number;
39
- lng: number;
40
- intensidad: number;
41
- }
42
-
43
- export interface IMapSearchAddressProps {
44
- configurationMap?: IConfigurationMap;
45
- coordinatesMap?: ICoords;
46
- coordinatesMapHeat?: IHeat[];
47
- }
48
-
49
- const props = withDefaults(defineProps<IMapSearchAddressProps>(), {
50
- configurationMap: () => {
51
- return {
52
- height: "250px",
53
- maxZoom: 20,
54
- iconMarker: {
55
- iconUrl: markerDefault,
56
- iconSize: [25, 41],
57
- iconAnchor: [12, 41],
58
- class: "",
59
- type: "image",
126
+ import {
127
+ Attribution,
128
+ FullScreen,
129
+ defaults as defaultControls,
130
+ } from "ol/control";
131
+ import { defineComponent } from "vue";
132
+
133
+ export default defineComponent({
134
+ name: "MapHeat",
135
+ props: {
136
+ coords: Object as any,
137
+ loadMapa: Object as any,
138
+ typeMap: String,
139
+ abrirCerrarLoader: Function,
140
+ onClickMarket: Function,
141
+ configurationMap: {
142
+ default: () => {
143
+ return {
144
+ strokeColor: "#f47521",
145
+ copyright: "&copy; 2021 Desarrollado por UTIC - Ministerio Público",
146
+ height: "250px",
147
+ maxZoom: 20,
148
+ iconMarker: {
149
+ iconUrl: "/image/gmap01.png",
150
+ iconSize: [25, 41],
151
+ iconAnchor: [12, 41],
152
+ class: "",
153
+ type: "image",
154
+ },
155
+ dragMarker: true,
156
+ };
60
157
  },
61
- dragMarker: true,
62
- };
63
- },
64
- coordinatesMap: () => {
65
- return {
66
- lat: -19.0429,
67
- lng: -65.2554,
68
- zoom: 12,
69
- };
158
+ },
70
159
  },
71
- coordinatesMapHeat: () => {
72
- return [];
160
+ data: () => ({
161
+ // store OL objects on the component instance
162
+ radius: 10,
163
+ blur: 20,
164
+ zoom: 5,
165
+ type: "0",
166
+ olMap: null as any,
167
+ heatLayer: null as any,
168
+ pointLayer: null as any,
169
+ countryLayer: null as any,
170
+ overlay: null as any,
171
+ showSetting: false,
172
+ cantidad: 0,
173
+ }),
174
+ watch: {
175
+ radius(value) {
176
+ this.setRadius(value);
177
+ },
178
+ blur(value) {
179
+ this.setBlur(value);
180
+ },
181
+ coords(value) {
182
+ this.cantidad = value.features.length;
183
+ this.updateSource(value);
184
+ this.updatePointSource(value);
185
+ },
186
+ loadMapa(val) {
187
+ this.changeCountryLayer(val);
188
+ },
189
+ typeMap(val) {
190
+ this.changeTypeMap(val);
191
+ },
192
+ type(type) {
193
+ this.changeTypeMap(type);
194
+ },
73
195
  },
74
- });
196
+ methods: {
197
+ changeTypeMap(type: string) {
198
+ if (type === "0") {
199
+ this.heatLayer.setVisible(true);
200
+ this.pointLayer.setVisible(false);
201
+ this.olMap.removeEventListener("click", this.onClickListener);
202
+ } else {
203
+ this.heatLayer.setVisible(false);
204
+ this.pointLayer.setVisible(true);
205
+ this.initClick();
206
+ }
207
+ },
208
+ initMap() {
209
+ const attributions = `<span class='map-copyright-text' >${this.configurationMap.copyright}</span>`;
210
+ const style = new Style({
211
+ stroke: new Stroke({
212
+ color: this.configurationMap.strokeColor,
213
+ width: 3,
214
+ }),
215
+ text: new Text({
216
+ font: "12px Roboto",
217
+ fill: new Fill({
218
+ color: "#000",
219
+ }),
220
+ stroke: new Stroke({
221
+ color: "#fff",
222
+ width: 1,
223
+ }),
224
+ }),
225
+ });
226
+ this.countryLayer = new VectorLayer({
227
+ source: new VectorSource({
228
+ url: `${this.loadMapa.data}`,
229
+ format: new GeoJSON(),
230
+ }),
231
+ style: function (feature) {
232
+ style.getText().setText(feature.get("name"));
233
+ return style;
234
+ },
235
+ });
75
236
 
76
- const emit = defineEmits(["updated:coordsMarker"]);
237
+ this.heatLayer = new HeatmapLayer({
238
+ source: new VectorSource({
239
+ features: [],
240
+ }),
241
+ visible: false,
242
+ radius: 10,
243
+ blur: 25,
244
+ });
77
245
 
78
- const idMap = ref();
79
- const coords = ref(props.coordinatesMap);
80
- const mapRender = ref();
81
- const markerRender = ref();
246
+ try {
247
+ this.pointLayer = this.configurationMap
248
+ ? new VectorLayer({
249
+ source: new VectorSource({
250
+ features: [],
251
+ }),
252
+ visible: false,
253
+ style: (feature) => {
254
+ const zIndex: any = 1;
255
+ const iconStyle = new Style({
256
+ image: new Icon({
257
+ opacity: 1,
258
+ src: this.configurationMap?.iconMarker?.iconUrl,
259
+ scale: 0.45,
260
+ // zIndex: zIndex,
261
+ }),
262
+ zIndex: zIndex,
263
+ });
264
+ return iconStyle;
265
+ },
266
+ })
267
+ : undefined;
268
+ } catch (e) {
269
+ console.log(e);
270
+ }
82
271
 
83
- onMounted(async () => {
84
- await makeid(10);
85
- await renderMap();
86
- });
272
+ this.olMap = new Map({
273
+ controls: defaultControls({ attribution: false })
274
+ .extend([new FullScreen({ tipLabel: "Pantalla completa" })])
275
+ .extend([
276
+ new Attribution({
277
+ collapsible: false,
278
+ }),
279
+ ]),
280
+ layers: [
281
+ new TileLayer({
282
+ source: new OSM({ attributions: attributions }),
283
+ }),
284
+ this.countryLayer,
285
+ this.heatLayer,
286
+ this.pointLayer,
287
+ ],
288
+ target: this.$refs["map-root"] as any,
87
289
 
88
- const makeid = async (length: number) => {
89
- let result = "";
90
- const characters = "abcdefghijklmnopqrstuvwxyz";
91
- const charactersLength = characters.length;
92
- let counter = 0;
93
- while (counter < length) {
94
- result += characters.charAt(Math.floor(Math.random() * charactersLength));
95
- counter += 1;
96
- }
97
- idMap.value = result;
98
- };
99
-
100
- const renderMap = async () => {
101
- await createMap();
102
- };
103
-
104
- const createMap = async () => {
105
- const iconMarker = props.configurationMap?.iconMarker;
106
- const map = L.map(idMap.value, { fullscreenControl: true } as any).setView(
107
- [coords.value.lat, coords.value.lng],
108
- coords.value.zoom
109
- );
110
- map.invalidateSize();
111
- mapRender.value = map;
112
- L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
113
- maxZoom: props.configurationMap?.maxZoom,
114
- attribution:
115
- '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
116
- }).addTo(map);
117
-
118
- const heatMap: any[] = props.coordinatesMapHeat.map((item: any) => [
119
- item.lat,
120
- item.lng,
121
- item.intensidad,
122
- ]);
123
- L.heatLayer(heatMap, { radius: 25 }).addTo(map);
124
-
125
- if (iconMarker.type === "image") {
126
- const marker = L.marker([coords.value.lat, coords.value.lng], {
127
- icon: L.icon({
128
- iconUrl: iconMarker.iconUrl,
129
- iconAnchor: iconMarker.iconAnchor,
130
- iconSize: iconMarker.iconSize,
131
- className: iconMarker.class,
132
- }),
133
- draggable: props.configurationMap.dragMarker,
134
- }).addTo(map);
135
- markerRender.value = marker;
136
- marker.on("dragend", (event) => {
137
- const updatedCoordinates = event.target.getLatLng();
138
- const lat = updatedCoordinates.lat;
139
- const lng = updatedCoordinates.lng;
140
- setCoordinates({
141
- lat,
142
- lng,
290
+ view: new View({
291
+ center: [0, 0],
292
+ zoom: this.zoom,
293
+ // minZoom: 5,
294
+ // maxZoom: 10,
295
+ }),
143
296
  });
144
- });
145
- } else if (iconMarker.type === "svg") {
146
- const marker = L.marker([coords.value.lat, coords.value.lng], {
147
- icon: L.divIcon({
148
- html: iconMarker.iconUrl,
149
- iconAnchor: iconMarker.iconAnchor,
150
- iconSize: iconMarker.iconSize,
151
- className: iconMarker.class,
152
- }),
153
- draggable: props.configurationMap.dragMarker,
154
- }).addTo(map);
155
- markerRender.value = marker;
156
- marker.on("dragend", (event) => {
157
- const updatedCoordinates = event.target.getLatLng();
158
- const lat = updatedCoordinates.lat;
159
- const lng = updatedCoordinates.lng;
160
- setCoordinates({
161
- lat,
162
- lng,
297
+ // coordenadas de la ciudad por defecto
298
+ const cord = fromLonLat([this.loadMapa.lng, this.loadMapa.lat]);
299
+ this.olMap.getView().adjustCenter(cord);
300
+ this.fitMap();
301
+ },
302
+ initClick() {
303
+ //init clicker
304
+ const container = document.getElementById("popup");
305
+ const closer: any = document.getElementById("popup-closer");
306
+ this.overlay = new Overlay({
307
+ element: container as any,
308
+ autoPan: true,
309
+ // autoPanAnimation: {
310
+ // duration: 250,
311
+ // },
163
312
  });
164
- });
165
- }
166
- };
167
-
168
- const searchAddress = async (query: string) => {
169
- // const address = await axios.get(
170
- // location.protocol + "//nominatim.openstreetmap.org/search?",
171
- // {
172
- // params: {
173
- // //query
174
- // q: query,
175
- // limit: 1,
176
- // format: "json",
177
- // },
178
- // }
179
- // );
180
- // if (address.data.length === 1) {
181
- // const lat = parseFloat(address.data[0].lat);
182
- // const lng = parseFloat(address.data[0].lon);
183
- // const coord = { lng, lat };
184
- // setCoordinates({ ...coord, moveMarker: true });
185
- // return address.data[0];
186
- // }
187
- // return address.data;
188
- };
189
-
190
- const setCoordinates = ({
191
- lat,
192
- lng,
193
- moveMarker = false,
194
- }: {
195
- lat: number;
196
- lng: number;
197
- moveMarker?: boolean;
198
- }) => {
199
- emit("updated:coordsMarker", {
200
- lat,
201
- lng,
202
- });
203
- if (moveMarker) markerRender.value?.setLatLng({ lat, lng });
204
- moveCenterTo({ lat, lng });
205
- };
206
-
207
- const moveCenterTo = ({ lat, lng }: { lat: number; lng: number }) => {
208
- const newCenter = L.latLng(lat, lng);
209
- mapRender.value.panTo(newCenter, { animate: true, duration: 0.5 });
210
- };
211
-
212
- defineExpose({
213
- searchAddress,
313
+ this.olMap.addOverlay(this.overlay);
314
+
315
+ closer.onclick = () => this.closeOverlay();
316
+ this.olMap.addEventListener("click", this.onClickListener);
317
+ },
318
+ closeOverlay() {
319
+ const closer: any = document.getElementById("popup-closer");
320
+ this.overlay.setPosition(undefined);
321
+ closer.blur();
322
+ return false;
323
+ },
324
+ async onClickListener(event: any) {
325
+ const content: any = document.getElementById("popup-content");
326
+ const closer: any = document.getElementById("popup-closer");
327
+
328
+ if (this.olMap.hasFeatureAtPixel(event.pixel) === true) {
329
+ const feature = this.olMap.getFeaturesAtPixel(event.pixel)[0];
330
+ const type = feature.getGeometry().getType();
331
+ if (type === "Point") {
332
+ const properties = this.olMap
333
+ .getFeaturesAtPixel(event.pixel)[0]
334
+ .getProperties();
335
+ const coordinate = event.coordinate;
336
+ if (this.abrirCerrarLoader) this.abrirCerrarLoader(true);
337
+ try {
338
+ if (this.abrirCerrarLoader) this.abrirCerrarLoader(false);
339
+ let html = "";
340
+ if (this.onClickMarket) html = await this.onClickMarket(properties);
341
+ content.innerHTML = html;
342
+ //centra el mapa en el punto con el mismo zoom
343
+ const view = this.olMap.getView();
344
+ const extent = feature.getGeometry().getExtent();
345
+ const oldCenter = view.getCenter();
346
+ const oldZoom = view.getZoom();
347
+ view.fit(extent, { padding: [325, 75, 0, 75], maxZoom: oldZoom });
348
+ const newCenter = view.getCenter();
349
+ view.setCenter(oldCenter);
350
+ view.animate({ center: newCenter });
351
+ } catch (e) {
352
+ if (this.abrirCerrarLoader) this.abrirCerrarLoader(false);
353
+ // toastr.warning('Ocurrio un error, consulte con el administrador');
354
+ }
355
+ this.overlay.setPosition(coordinate);
356
+ }
357
+ } else {
358
+ this.overlay.setPosition(undefined);
359
+ closer.blur();
360
+ }
361
+ },
362
+ updateSource(coords: any) {
363
+ if (coords && coords.features.length === 0) {
364
+ const source = this.heatLayer.getSource();
365
+ source.clear();
366
+ return;
367
+ }
368
+ if (coords) {
369
+ const source = this.heatLayer.getSource();
370
+
371
+ const features = new GeoJSON({
372
+ featureProjection: "EPSG:3857",
373
+ }).readFeatures(coords);
374
+
375
+ source.clear();
376
+ source.addFeatures(features);
377
+ }
378
+ },
379
+ updatePointSource(coords: any) {
380
+ if (coords && coords.features.length === 0) {
381
+ const source = this.pointLayer.getSource();
382
+ source.clear();
383
+ return;
384
+ }
385
+ if (coords) {
386
+ const source = this.pointLayer.getSource();
387
+
388
+ const features = new GeoJSON({
389
+ featureProjection: "EPSG:3857",
390
+ }).readFeatures(coords);
391
+
392
+ source.clear();
393
+ source.addFeatures(features);
394
+ }
395
+ },
396
+ async changeCountryLayer(data: any) {
397
+ const source = this.countryLayer;
398
+ if (source) {
399
+ const src = new VectorSource({
400
+ url: `${data.data}`,
401
+ format: new GeoJSON(),
402
+ });
403
+ await this.countryLayer.setSource(src);
404
+ }
405
+ },
406
+ fitMap() {
407
+ // this zooms the view on the created object
408
+ this.countryLayer.addEventListener("change", this.countryFunction);
409
+ },
410
+ countryFunction(evt: any) {
411
+ const view = this.olMap.getView();
412
+
413
+ const feature = evt.target.getSource().getFeatures()[0];
414
+ if (feature) {
415
+ const extent = evt.target.getSource().getExtent();
416
+ const oldZoom = view.getZoom();
417
+ const oldCenter = view.getCenter();
418
+ view.fit(extent, { padding: [75, 75, 75, 75], maxZoom: 6 });
419
+ const newZoom = view.getZoom();
420
+ const newCenter = view.getCenter();
421
+ view.setCenter(oldCenter);
422
+ view.setZoom(oldZoom);
423
+ view.animate({ center: newCenter });
424
+ view.animate({ zoom: newZoom });
425
+ }
426
+ },
427
+ setRadius(radius: any) {
428
+ this.heatLayer.setRadius(parseInt(radius, 10));
429
+ },
430
+ setBlur(blur: any) {
431
+ this.heatLayer.setBlur(parseInt(blur, 10));
432
+ },
433
+ irACiudad() {
434
+ if (this.loadMapa)
435
+ if (this.loadMapa.country !== "Bolivia") {
436
+ const view = this.olMap.getView();
437
+ const oldZoom = view.getZoom();
438
+ const oldCenter = view.getCenter();
439
+ view.setCenter(fromLonLat([this.loadMapa.lng, this.loadMapa.lat]));
440
+ const newZoom = 13;
441
+ const newCenter = view.getCenter();
442
+ view.setCenter(oldCenter);
443
+ view.setZoom(oldZoom);
444
+ view.animate({ center: newCenter });
445
+ view.animate({ zoom: newZoom });
446
+ }
447
+ },
448
+ toggleSettings() {
449
+ this.showSetting = !this.showSetting;
450
+ },
451
+ },
452
+ mounted() {
453
+ this.countryLayer = this.loadMapa;
454
+ this.initMap();
455
+ },
456
+ beforeDestroy() {
457
+ this.countryLayer.removeEventListener("change", this.countryFunction);
458
+ this.olMap.removeEventListener("click", this.onClickListener);
459
+ },
214
460
  });
215
461
  </script>
462
+ <style lang="scss" scoped>
463
+ .text-cantidad {
464
+ color: #000 !important;
465
+ margin: 0;
466
+ font-size: 16px;
467
+ padding: 0 1rem;
468
+ }
469
+ .cant-casos {
470
+ position: absolute;
471
+ right: 0;
472
+ bottom: 24px;
473
+ z-index: 10;
474
+ }
475
+ .map-container {
476
+ flex: 1;
477
+ }
478
+ @media only screen and (max-width: 600px) {
479
+ .map-container {
480
+ flex: none;
481
+ height: 65%;
482
+ }
483
+ }
484
+ .btn-settings {
485
+ z-index: 10;
486
+ bottom: 0.5em;
487
+ left: 0.5em;
488
+ }
489
+ .btn-icon {
490
+ font-size: 12px;
491
+ }
492
+ .btn-zoom-container {
493
+ z-index: 10;
494
+ top: 4.5em;
495
+ left: 0.5em;
496
+ }
497
+ .type-map-container {
498
+ z-index: 10;
499
+ top: 7em;
500
+ left: 0.5em;
501
+ }
502
+ .control-container {
503
+ color: #fff;
504
+ position: absolute;
505
+ bottom: 0;
506
+ z-index: 1;
507
+ left: 0;
508
+ background: rgba(0, 0, 0, 0.4);
509
+ padding: 16px;
510
+ & .map-flex {
511
+ display: flex;
512
+ flex-direction: column;
513
+ & label {
514
+ font-family: Roboto;
515
+ font-weight: 600;
516
+ font-size: 12px;
517
+ }
518
+ & input[type="range"] {
519
+ accent-color: var(--primary-color, #f28b0c);
520
+ // color: red;
521
+ }
522
+ }
523
+ }
524
+ </style>
525
+
526
+ <style lang="scss">
527
+ button.jl2-button-map {
528
+ background-color: #f29512;
529
+ /* padding: 1rem; */
530
+ & svg {
531
+ width: 12px;
532
+ height: 12px;
533
+ fill: white;
534
+ }
535
+ &:hover {
536
+ background: #f28b0c;
537
+ border: none !important;
538
+ outline: none;
539
+ }
540
+ }
541
+ button.jl2-button-map-select {
542
+ // border: 1px solid #4e5358;
543
+ & svg {
544
+ fill: #4e5358;
545
+ }
546
+ }
547
+
548
+ .ol-control button {
549
+ color: white;
550
+ background-color: var(--primary-light-color, #f29512);
551
+ }
552
+ .ol-control button:focus,
553
+ .ol-control button:hover {
554
+ background-color: var(--primary-color, #f28b0c);
555
+ cursor: pointer;
556
+ border: none !important;
557
+ outline: none;
558
+ color: white;
559
+ }
560
+
561
+ .align-img {
562
+ text-align: center;
563
+ // height: 10px;
564
+ // width: 10px;
565
+ }
566
+ .rotate-north {
567
+ top: 65px;
568
+ left: 0.5em;
569
+ }
570
+ .ol-touch .rotate-north {
571
+ top: 80px;
572
+ }
573
+ .ol-popup {
574
+ font-size: 12px;
575
+ position: absolute;
576
+ background-color: white;
577
+ -webkit-filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
578
+ filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
579
+ padding: 0px 10px 0px 10px;
580
+ border-radius: 10px;
581
+ border: 1px solid #cccccc;
582
+ bottom: 12px;
583
+ left: -50px;
584
+ min-width: 190px;
585
+ font-family: "Roboto";
586
+ & .ol-title {
587
+ letter-spacing: 1px;
588
+ font-size: 14px;
589
+ font-weight: 700;
590
+ margin-bottom: 5px;
591
+ text-align: center;
592
+ color: #4e5358 !important;
593
+ }
594
+ & .ol-bold {
595
+ font-weight: 600;
596
+ }
597
+ & .ol-text {
598
+ font-weight: 300;
599
+ color: #4e5358 !important;
600
+ margin: 0px;
601
+ margin-top: 6px;
602
+ margin-bottom: 6px;
603
+ }
604
+ }
216
605
 
217
- <style lang="scss"></style>
606
+ .ol-popup:after,
607
+ .ol-popup:before {
608
+ top: 100%;
609
+ border: solid transparent;
610
+ content: " ";
611
+ height: 0;
612
+ width: 0;
613
+ position: absolute;
614
+ pointer-events: none;
615
+ }
616
+ .ol-popup:after {
617
+ border-top-color: white;
618
+ border-width: 10px;
619
+ left: 48px;
620
+ margin-left: -10px;
621
+ }
622
+ .ol-popup:before {
623
+ border-top-color: #cccccc;
624
+ border-width: 11px;
625
+ left: 48px;
626
+ margin-left: -11px;
627
+ }
628
+ .ol-popup-closer {
629
+ text-decoration: none;
630
+ position: absolute;
631
+ top: -8px;
632
+ right: -8px;
633
+ padding: 3px 4px;
634
+ border-radius: 1rem;
635
+ background-color: var(--primary-light-color, #f29512);
636
+ }
637
+ .ol-popup-closer:after {
638
+ display: flex;
639
+ align-content: center;
640
+ font-size: 12px;
641
+ content: "✖";
642
+ color: white;
643
+ }
644
+ .ol-popup-closer:hover::after {
645
+ content: "✖";
646
+ background-color: var(--primary-color, #f28b0c);
647
+ }
648
+ .map-copyright-text {
649
+ font-size: 12px;
650
+ font-weight: 600px;
651
+ // font-family: Roboto;
652
+ }
653
+ </style>