Skip to content
Snippets Groups Projects
Commit 972c149d authored by Etienne LOUPIAS's avatar Etienne LOUPIAS
Browse files

fix(map): avoid console error for structure without position

parent 6edc0f27
Branches
Tags
1 merge request!608V2.4.2
......@@ -194,6 +194,10 @@ export class MapComponent implements OnChanges {
private getStructuresPositions(structureList: Structure[]): void {
for (const structure of structureList) {
if (!(structure.getLat() && structure.getLon())) {
console.log(`Pas de position pour ${structure.structureName}`);
continue;
}
this.mapService
.createMarker(
structure.getLat(),
......
......@@ -16,7 +16,6 @@ import {
})
export class MapService {
private static markersList = {};
private isMarkerActive = false;
public createMarker(lat: number, lon: number, markerType: MarkerType, id?: string, popup?: string): Marker {
const marker = new Marker([lat, lon], {
......@@ -100,7 +99,7 @@ export class MapService {
* @param id marker id
*/
public setActiveMarker(id: string, type: MarkerType = MarkerType.structure): void {
this.getMarker(id).setIcon(this.getHoverMarkerIcon(type));
this.getMarker(id)?.setIcon(this.getHoverMarkerIcon(type));
}
public setAddedToListMarker(id: string, type: MarkerType = MarkerType.structure): void {
......@@ -110,7 +109,6 @@ export class MapService {
public setInactiveMarker(id: string, type: MarkerType = MarkerType.structure): void {
// To skip mouseleave when user emit click on structure list
this.getMarker(id)?.setIcon(this.getMarkerIcon(type));
this.isMarkerActive = false;
}
/**
......@@ -121,7 +119,6 @@ export class MapService {
public setSelectedMarker(id: string, type: MarkerType = MarkerType.structure): void {
if (id) {
this.getMarker(id)?.setIcon(this.getActiveMarkerIcon(type));
this.isMarkerActive = true;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment