diff --git a/src/iotMapManager/css/map.css b/src/iotMapManager/css/map.css index 1527574c..62feb499 100644 --- a/src/iotMapManager/css/map.css +++ b/src/iotMapManager/css/map.css @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * diff --git a/src/iotMapManager/css/markers.css b/src/iotMapManager/css/markers.css index 47da097d..2f5976c3 100644 --- a/src/iotMapManager/css/markers.css +++ b/src/iotMapManager/css/markers.css @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * diff --git a/src/iotMapManager/css/popup.css b/src/iotMapManager/css/popup.css index 6d0f6db9..a26e8e26 100644 --- a/src/iotMapManager/css/popup.css +++ b/src/iotMapManager/css/popup.css @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * diff --git a/src/iotMapManager/css/tabs.css b/src/iotMapManager/css/tabs.css index ea1f1b95..6c56c3f3 100644 --- a/src/iotMapManager/css/tabs.css +++ b/src/iotMapManager/css/tabs.css @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * diff --git a/src/iotMapManager/import_png.d.ts b/src/iotMapManager/import_png.d.ts index 2049e003..a8518147 100644 --- a/src/iotMapManager/import_png.d.ts +++ b/src/iotMapManager/import_png.d.ts @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * diff --git a/src/iotMapManager/index.ts b/src/iotMapManager/index.ts index 7d791dde..135c75cc 100644 --- a/src/iotMapManager/index.ts +++ b/src/iotMapManager/index.ts @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * diff --git a/src/iotMapManager/iot-map-manager.css b/src/iotMapManager/iot-map-manager.css index 149adecc..b49320e4 100644 --- a/src/iotMapManager/iot-map-manager.css +++ b/src/iotMapManager/iot-map-manager.css @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * diff --git a/src/iotMapManager/package.json b/src/iotMapManager/package.json index 1654a6aa..3a2a0405 100644 --- a/src/iotMapManager/package.json +++ b/src/iotMapManager/package.json @@ -1,6 +1,6 @@ { "name": "iotmapmanager", - "version": "2.6.2", + "version": "2.6.5", "description": "Manage markers, clusters, user marker or paths on IotMaps", "main": "dist/index.js", "types": "lib/index.d.ts", diff --git a/src/iotMapManager/readme.md b/src/iotMapManager/readme.md index f20eb116..76ecb27a 100644 --- a/src/iotMapManager/readme.md +++ b/src/iotMapManager/readme.md @@ -1,4 +1,4 @@ -# IotMapManager V2.6.2 +# IotMapManager V2.6.5 This library provides management of markers dedicated to projects using mapping. ## use @@ -250,6 +250,7 @@ interface Inner { } ``` +Note: the icon has priority over the label. To update a marker having an icon by a label, set `icon` to `null` and define a label. diff --git a/src/iotMapManager/src/iot-map-area-manager.ts b/src/iotMapManager/src/iot-map-area-manager.ts index 8a9ce711..c2607e47 100644 --- a/src/iotMapManager/src/iot-map-area-manager.ts +++ b/src/iotMapManager/src/iot-map-area-manager.ts @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * diff --git a/src/iotMapManager/src/iot-map-area.ts b/src/iotMapManager/src/iot-map-area.ts index 7ab713cd..efb0b63b 100644 --- a/src/iotMapManager/src/iot-map-area.ts +++ b/src/iotMapManager/src/iot-map-area.ts @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * diff --git a/src/iotMapManager/src/iot-map-cluster-manager.ts b/src/iotMapManager/src/iot-map-cluster-manager.ts index 4c4d833e..f4be166d 100644 --- a/src/iotMapManager/src/iot-map-cluster-manager.ts +++ b/src/iotMapManager/src/iot-map-cluster-manager.ts @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * @@ -76,10 +76,7 @@ export class IotMapClusterManager { const clusterToRemove: IotMapCluster = this.clustersObjects[clusterId] if (clusterToRemove) { clusterToRemove.removeCluster() - const index = this.clustersObjects.indexOf(clusterToRemove, 0) - if (index > -1) { - this.clustersObjects.splice(index, 1) - } + delete this.clustersObjects[clusterId] } } } diff --git a/src/iotMapManager/src/iot-map-cluster.ts b/src/iotMapManager/src/iot-map-cluster.ts index 0159e741..36359aa3 100644 --- a/src/iotMapManager/src/iot-map-cluster.ts +++ b/src/iotMapManager/src/iot-map-cluster.ts @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * diff --git a/src/iotMapManager/src/iot-map-common-svg.ts b/src/iotMapManager/src/iot-map-common-svg.ts index d49cd2b2..844670b2 100644 --- a/src/iotMapManager/src/iot-map-common-svg.ts +++ b/src/iotMapManager/src/iot-map-common-svg.ts @@ -1,6 +1,6 @@ /* * Software Name: IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * diff --git a/src/iotMapManager/src/iot-map-config.ts b/src/iotMapManager/src/iot-map-config.ts index a5e377d2..af4245e3 100644 --- a/src/iotMapManager/src/iot-map-config.ts +++ b/src/iotMapManager/src/iot-map-config.ts @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * diff --git a/src/iotMapManager/src/iot-map-icons.ts b/src/iotMapManager/src/iot-map-icons.ts index e0f71017..4bb6afbc 100644 --- a/src/iotMapManager/src/iot-map-icons.ts +++ b/src/iotMapManager/src/iot-map-icons.ts @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * @@ -88,7 +88,7 @@ export function getManualClusterIcon (cluster: IotCluster, config: IotMapConfig) // popup const layerTemp = config.layerTemplates[cluster.layer] - const nbCols = (cluster.colNumber ?? layerTemp?.popupColNumber) ?? 1 + const nbCols = (cluster.aggregation.length === 1) ? 1 : (cluster.colNumber ?? layerTemp?.popupColNumber) ?? 1 let popup = (nbCols > 1) ? `
` : `
` diff --git a/src/iotMapManager/src/iot-map-manager.ts b/src/iotMapManager/src/iot-map-manager.ts index 82f9d287..5163f459 100644 --- a/src/iotMapManager/src/iot-map-manager.ts +++ b/src/iotMapManager/src/iot-map-manager.ts @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * @@ -92,8 +92,8 @@ export class IotMapManager { if (this.config.map.externalClustering) { // manual clustering layer = new L.FeatureGroup() layer.on('click', this.onElementClick.bind(this)) - .on('mouseover', this.onMarkerMouseOver) - .on('mouseout', this.onMarkerMouseOut) + .on('mouseover', this.onElementMouseOver.bind(this)) + .on('mouseout', this.onElementMouseOut) } else if (layerName === this.config.accuracyCircle.layerName || layerName === this.config.userMarker.layerName || layerName === this.config.path.layerName) { // accuracy area, user marker or path = no clustering @@ -106,7 +106,7 @@ export class IotMapManager { }) layer.on('animationend', this.onZoom.bind(this)) - .on('clustermouseover', this.onClusterMouseOver) + .on('clustermouseover', this.onClusterMouseOver.bind(this)) .on('clustermouseout', this.onClusterMouseOut) .on('click', this.onElementClick.bind(this)) } @@ -249,13 +249,16 @@ export class IotMapManager { * @param event - event data */ private onElementClick (event) { - const element = event.layer - element.elementClicked() // informe cluster to open + const element: IotMapDisplay = event.layer + if (this.selectedElement === element) { this.unselectElement(element) } else { this.selectElement(element) } + + element.elementClicked() // inform cluster to open + element.shiftMap() } /** @@ -278,7 +281,7 @@ export class IotMapManager { * Called on marker mouse over (to brind manual cluster in front) * @param event - event data */ - private onMarkerMouseOver (event) { + private onElementMouseOver (event) { event.layer.setZIndexOffset(100) } @@ -286,7 +289,7 @@ export class IotMapManager { * Called on marker mouse out (to brind manual cluster in background) * @param event - event data */ - private onMarkerMouseOut (event) { + private onElementMouseOut (event) { event.layer.setZIndexOffset(0) } diff --git a/src/iotMapManager/src/iot-map-marker-manager.ts b/src/iotMapManager/src/iot-map-marker-manager.ts index 030006bf..9ac648af 100644 --- a/src/iotMapManager/src/iot-map-marker-manager.ts +++ b/src/iotMapManager/src/iot-map-marker-manager.ts @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * @@ -68,11 +68,7 @@ export class IotMapMarkerManager { const markerToRemove: IotMapMarker = this.markersObjects[markerId] if (markerToRemove) { markerToRemove.removeMarker() - - const index = this.markersObjects.indexOf(markerToRemove, 0) - if (index > -1) { - this.markersObjects.splice(index, 1) - } + delete this.markersObjects[markerId] } } diff --git a/src/iotMapManager/src/iot-map-marker.ts b/src/iotMapManager/src/iot-map-marker.ts index d7135eef..3013143a 100644 --- a/src/iotMapManager/src/iot-map-marker.ts +++ b/src/iotMapManager/src/iot-map-marker.ts @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * @@ -51,6 +51,11 @@ export class IotMapMarker extends IotMapDisplay { this.selected = selected this.setIcon(getMarkerIcon(this.data, this.config, selected)) this.setZIndexOffset((selected) ? 100 : 0) + + // if (this.selected && this.data.popup !== undefined) { + // // move map if marker is too close to the edge + // this.shiftMap() + // } } public getData (): IotMarker { @@ -109,4 +114,38 @@ export class IotMapMarker extends IotMapDisplay { this.map.getLayer(this.config.accuracyCircle.layerName).removeLayer(this.accuracyCircle) } } + + public shiftMap (): void { + if (this.selected && this.data.popup !== undefined) { + const eltPos = this.map.getIotMap().latLngToLayerPoint(this.data.location) + const mapBounds = this.map.getIotMap().getBounds() + const northEastPos = this.map.getIotMap().latLngToLayerPoint(mapBounds.getNorthEast()) + const southWestPos = this.map.getIotMap().latLngToLayerPoint(mapBounds.getSouthWest()) + + // top + if (eltPos.y - northEastPos.y < 200) { + const shift = 200 - (eltPos.y - northEastPos.y) + northEastPos.y -= shift + southWestPos.y -= shift + } + + // left + if (eltPos.x - southWestPos.x < 150) { + const shift = 150 - (eltPos.x - southWestPos.x) + northEastPos.x -= shift + southWestPos.x -= shift + } + + // bottom - no need to shift + // right + if (northEastPos.x - eltPos.x < 150) { + const shift = 150 - (northEastPos.x - eltPos.x) + northEastPos.x += shift + southWestPos.x += shift + } + + const newMapBounds = L.latLngBounds(this.map.getIotMap().layerPointToLatLng(southWestPos), this.map.getIotMap().layerPointToLatLng(northEastPos)) + this.map.getIotMap().flyToBounds(newMapBounds) + } + } } diff --git a/src/iotMapManager/src/iot-map-path-manager.ts b/src/iotMapManager/src/iot-map-path-manager.ts index fcbc1d39..18934cdc 100644 --- a/src/iotMapManager/src/iot-map-path-manager.ts +++ b/src/iotMapManager/src/iot-map-path-manager.ts @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * diff --git a/src/iotMapManager/src/iot-map-path.ts b/src/iotMapManager/src/iot-map-path.ts index c6555ea8..ecdd4737 100644 --- a/src/iotMapManager/src/iot-map-path.ts +++ b/src/iotMapManager/src/iot-map-path.ts @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * diff --git a/src/iotMapManager/src/iot-map-types.ts b/src/iotMapManager/src/iot-map-types.ts index 97ae17aa..d85a16e4 100644 --- a/src/iotMapManager/src/iot-map-types.ts +++ b/src/iotMapManager/src/iot-map-types.ts @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * @@ -52,6 +52,10 @@ export abstract class IotMapDisplay extends L.Marker { // By default: Nothing to do } + shiftMap (): void { + // By default: Nothing to do + } + updateAccuracyDisplay (selectedLayers: string[], display: boolean): void { // eslint-disable-line @typescript-eslint/no-unused-vars // By default: Nothing to do } diff --git a/src/iotMapManager/src/iot-map-user-marker-manager.ts b/src/iotMapManager/src/iot-map-user-marker-manager.ts index 55ef1a0c..d922b6b8 100644 --- a/src/iotMapManager/src/iot-map-user-marker-manager.ts +++ b/src/iotMapManager/src/iot-map-user-marker-manager.ts @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT * diff --git a/src/iotMapManager/src/iot-map-user-marker.ts b/src/iotMapManager/src/iot-map-user-marker.ts index 42dee201..c0fdab46 100644 --- a/src/iotMapManager/src/iot-map-user-marker.ts +++ b/src/iotMapManager/src/iot-map-user-marker.ts @@ -1,6 +1,6 @@ /* * Software Name : IotMapManager -* Version: 2.6.2 +* Version: 2.6.5 * SPDX-FileCopyrightText: Copyright (c) 2020 Orange * SPDX-License-Identifier: MIT *