Skip to content
Snippets Groups Projects
Commit b6f7966f authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

fix: cleaning makers was removing mdm layer

parent f4396dae
No related branches found
No related tags found
1 merge request!31Recette
......@@ -8,7 +8,19 @@ import {
SimpleChanges,
ViewChild,
} from '@angular/core';
import { latLng, MapOptions, tileLayer, Map, CRS, TileLayer, LatLngBounds, latLngBounds, Marker } from 'leaflet';
import {
latLng,
MapOptions,
tileLayer,
Map,
CRS,
TileLayer,
LatLngBounds,
latLngBounds,
Marker,
layerGroup,
polyline,
} from 'leaflet';
import { Observable } from 'rxjs';
import { mergeMap } from 'rxjs/operators';
import { Structure } from '../../models/structure.model';
......@@ -86,8 +98,7 @@ export class MapComponent implements OnChanges {
previousStructuresValue.length > 0 &&
previousStructuresValue.length < this.structures.length
) {
const newStructures = _.differenceWith(this.structures, previousStructuresValue, _.isEqual);
this.getStructuresPositions(newStructures);
this.getStructuresPositions(_.differenceWith(this.structures, previousStructuresValue, _.isEqual));
} else if (this.structures) {
this.map = this.mapService.cleanMap(this.map);
this.getStructuresPositions(this.structures);
......@@ -180,6 +191,7 @@ export class MapComponent implements OnChanges {
// Init mdm
this.initMDMLayer();
// Init WMS service with param from data.grandlyon.com
layerGroup();
const carteLayer = tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png', {
attribution: '&copy; <a href="https://carto.com/attributions">CARTO</a>',
maxZoom: 19,
......
......@@ -32,10 +32,10 @@ export class MapService {
const markerIcon = divIcon({
className: null,
html: '<svg width="19" height="24"><use xlink:href="assets/ico/sprite.svg#mdm"></use></svg>',
iconSize: [35, 41],
iconAnchor: [13, 41],
iconSize: [19, 24],
iconAnchor: [19, 24],
});
return new Marker([lat, lon], { icon: markerIcon });
return new Marker([lat, lon], { icon: markerIcon, attribution: 'mdm' });
}
/**
......@@ -102,7 +102,9 @@ export class MapService {
MapService.markersList = {};
if (map) {
map.eachLayer((layer) => {
if (layer instanceof Marker) map.removeLayer(layer);
if (layer instanceof Marker && layer.options.attribution !== 'mdm') {
map.removeLayer(layer);
}
});
}
return map;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment