vue-geojson-view-ts 1.3.8 → 1.3.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-geojson-view-ts",
3
- "version": "1.3.8",
3
+ "version": "1.3.10",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -199,7 +199,6 @@ export default defineComponent({
199
199
  },
200
200
  methods: {
201
201
  changeTypeMap(type: string) {
202
- this.type = type;
203
202
  if (type === "0") {
204
203
  this.heatLayer.setVisible(true);
205
204
  this.pointLayer.setVisible(false);
@@ -330,7 +329,6 @@ export default defineComponent({
330
329
  return false;
331
330
  },
332
331
  async onClickListener(event: any) {
333
- this.changeTypeMap("1");
334
332
  const content: any = document.getElementById("popup-content");
335
333
  const closer: any = document.getElementById("popup-closer");
336
334
 
@@ -13,8 +13,8 @@ import "leaflet/dist/leaflet.css";
13
13
  import "leaflet-draw/dist/leaflet.draw.css";
14
14
  import drawLocales from "leaflet-draw-locales";
15
15
  import axios from "axios";
16
- import 'leaflet.fullscreen/Control.FullScreen.css'
17
- import 'leaflet.fullscreen'
16
+ import "leaflet.fullscreen/Control.FullScreen.css";
17
+ import "leaflet.fullscreen";
18
18
 
19
19
  declare global {
20
20
  interface Window {
@@ -136,7 +136,7 @@ export default defineComponent({
136
136
  : this.markerIcon
137
137
  : this.markerIcon;
138
138
  window.type = true;
139
- const map = L.map(this.idMap,{fullscreenControl:true} as any).setView(
139
+ const map = L.map(this.idMap, { fullscreenControl: true } as any).setView(
140
140
  [
141
141
  this.renderCoordinates ? (this.renderCoordinates[0] as number) : 0,
142
142
  this.renderCoordinates ? (this.renderCoordinates[1] as number) : 0,
@@ -203,8 +203,14 @@ export default defineComponent({
203
203
  icon: L.icon(iconDefaultMarket),
204
204
  }
205
205
  : false,
206
- polyline: false,
207
- circlemarker: false,
206
+ polyline: this.configurationMap?.createFigures.polyline
207
+ ? {
208
+ shapeOptions: {
209
+ color: "blue",
210
+ },
211
+ }
212
+ : false,
213
+ circlemarker: this.configurationMap?.createFigures.multipoint,
208
214
  },
209
215
  edit: contextEdit as any,
210
216
  });
@@ -213,7 +219,37 @@ export default defineComponent({
213
219
  map.on("draw:created", (event: any) => {
214
220
  const layer = event.layer;
215
221
  featureGroup.addLayer(layer);
216
- const geojson = layer.toGeoJSON();
222
+ let geojson = layer.toGeoJSON();
223
+ // *** AGREGADO: Manejo especial para CircleMarker (convertir a MultiPoint) ***
224
+ if (event.layerType === "circlemarker") {
225
+ // Convertir CircleMarker a formato MultiPoint para consistencia
226
+ geojson = {
227
+ type: "Feature",
228
+ geometry: {
229
+ type: "MultiPoint",
230
+ coordinates: [geojson.geometry.coordinates],
231
+ },
232
+ properties: {
233
+ ...geojson.properties,
234
+ pointType: "multipoint",
235
+ style: {
236
+ color:
237
+ this.configurationMap?.createFigures?.multipoint?.color ||
238
+ "green",
239
+ fillColor:
240
+ this.configurationMap?.createFigures?.multipoint?.fillColor ||
241
+ "green",
242
+ fillOpacity:
243
+ this.configurationMap?.createFigures?.multipoint
244
+ ?.fillOpacity || 0.8,
245
+ radius:
246
+ this.configurationMap?.createFigures?.multipoint?.radius || 6,
247
+ weight:
248
+ this.configurationMap?.createFigures?.multipoint?.weight || 2,
249
+ },
250
+ },
251
+ };
252
+ }
217
253
  if (this.getGeoJSON) this.getGeoJSON([geojson]);
218
254
  });
219
255
 
@@ -232,17 +268,15 @@ export default defineComponent({
232
268
  : this.markerIcon
233
269
  : this.markerIcon;
234
270
  window.type = true;
235
- const map = L.map(this.idMap,{fullscreenControl:true} as any).setView(
271
+ const map = L.map(this.idMap, { fullscreenControl: true } as any).setView(
236
272
  [
237
273
  this.renderCoordinates ? (this.renderCoordinates[0] as number) : 0,
238
274
  this.renderCoordinates ? (this.renderCoordinates[1] as number) : 0,
239
275
  ],
240
276
  this.renderCoordinates ? (this.renderCoordinates[2] as number) : 0
241
277
  );
242
- //const map = L.map(this.idMap,{minZoom: 15,maxZoom: 500}).setView([this.renderCoordinates?this.renderCoordinates[0] as number:0,this.renderCoordinates?this.renderCoordinates[1] as number:0],this.renderCoordinates?this.renderCoordinates[2]as number:0);
243
278
  this.mapRender = map;
244
279
  L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
245
- //maxZoom: 120,//this.configurationMap?.maxZoom,
246
280
  attribution:
247
281
  '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
248
282
  }).addTo(map);
@@ -270,10 +304,13 @@ export default defineComponent({
270
304
  item.features.forEach((feature: any) => {
271
305
  if (
272
306
  feature.geometry.type === "Polygon" ||
273
- feature.geometry.type === "MultiPolygon"
307
+ feature.geometry.type === "MultiPolygon" ||
308
+ feature.geometry.type === "LineString" ||
309
+ feature.geometry.type === "MultiLineString" ||
310
+ feature.geometry.type === "Point"
274
311
  ) {
275
- //L.geoJSON(feature).addTo(featureGroup);
276
312
  L.geoJson(feature, {
313
+ pointToLayer: this.getPointToLayer.bind(this),
277
314
  onEachFeature: function (feature, layer) {
278
315
  featureGroup.addLayer(layer);
279
316
  },
@@ -283,9 +320,12 @@ export default defineComponent({
283
320
  } else if (item.type === "Feature") {
284
321
  if (
285
322
  item.geometry.type === "Polygon" ||
286
- item.geometry.type === "MultiPolygon"
323
+ item.geometry.type === "MultiPolygon" ||
324
+ item.geometry.type === "LineString" ||
325
+ item.geometry.type === "MultiLineString" ||
326
+ item.geometry.type === "Point" ||
327
+ item.geometry.type === "MultiPoint"
287
328
  ) {
288
- //L.geoJSON(item).addTo(featureGroup);
289
329
  L.geoJson(item, {
290
330
  onEachFeature: function (feature, layer) {
291
331
  featureGroup.addLayer(layer);
@@ -314,8 +354,14 @@ export default defineComponent({
314
354
  icon: L.icon(iconDefaultMarket),
315
355
  }
316
356
  : false,
317
- polyline: false,
318
- circlemarker: false,
357
+ polyline: this.configurationMap?.createFigures.polyline
358
+ ? {
359
+ shapeOptions: {
360
+ color: "blue",
361
+ },
362
+ }
363
+ : false,
364
+ circlemarker: this.configurationMap?.createFigures.multipoint,
319
365
  },
320
366
  edit: contextEdit as any,
321
367
  });
@@ -324,7 +370,37 @@ export default defineComponent({
324
370
  map.on("draw:created", (event: any) => {
325
371
  const layer = event.layer;
326
372
  featureGroup.addLayer(layer);
327
- const geojson = layer.toGeoJSON();
373
+ let geojson = layer.toGeoJSON();
374
+ // *** AGREGADO: Manejo especial para CircleMarker (convertir a MultiPoint) ***
375
+ if (event.layerType === "circlemarker") {
376
+ // Convertir CircleMarker a formato MultiPoint para consistencia
377
+ geojson = {
378
+ type: "Feature",
379
+ geometry: {
380
+ type: "MultiPoint",
381
+ coordinates: [geojson.geometry.coordinates],
382
+ },
383
+ properties: {
384
+ ...geojson.properties,
385
+ pointType: "multipoint",
386
+ style: {
387
+ color:
388
+ this.configurationMap?.createFigures?.multipoint?.color ||
389
+ "green",
390
+ fillColor:
391
+ this.configurationMap?.createFigures?.multipoint?.fillColor ||
392
+ "green",
393
+ fillOpacity:
394
+ this.configurationMap?.createFigures?.multipoint
395
+ ?.fillOpacity || 0.8,
396
+ radius:
397
+ this.configurationMap?.createFigures?.multipoint?.radius || 6,
398
+ weight:
399
+ this.configurationMap?.createFigures?.multipoint?.weight || 2,
400
+ },
401
+ },
402
+ };
403
+ }
328
404
  if (this.getGeoJSON) this.getGeoJSON(geojson);
329
405
  });
330
406
 
@@ -336,6 +412,38 @@ export default defineComponent({
336
412
  });
337
413
  });
338
414
  },
415
+ getPointToLayer(feature: any, latlng: any) {
416
+ const geometryType = feature.geometry?.type;
417
+
418
+ // Point: icono según properties.tipo
419
+ if (geometryType === "Point") {
420
+ const tipo = feature.properties?.tipo;
421
+ const firstIcon = L.icon({
422
+ iconUrl: "/image/home.png",
423
+ iconSize: [38, 38],
424
+ iconAnchor: [16, 41],
425
+ });
426
+ const lastIcon = L.icon({
427
+ iconUrl: "/image/end.png",
428
+ iconSize: [38, 38],
429
+ iconAnchor: [16, 41],
430
+ });
431
+ const pointerIcon = L.icon({
432
+ iconUrl: "/image/tracking.png",
433
+ iconSize: [38, 38],
434
+ iconAnchor: [16, 41],
435
+ });
436
+
437
+ let icon = pointerIcon;
438
+ if (tipo === 0) icon = firstIcon;
439
+ else if (tipo === 1) icon = lastIcon;
440
+
441
+ return L.marker(latlng, { icon });
442
+ }
443
+
444
+ // Otros tipos: icono por defecto
445
+ return L.marker(latlng);
446
+ },
339
447
  async searchAddress(query: string) {
340
448
  const address = await axios.get(
341
449
  location.protocol + "//nominatim.openstreetmap.org/search?",