Skip to content

Commit

Permalink
Merge branch 'master' into png-inner-icon
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/iotMapManager/src/iot-map-marker-manager.ts
  • Loading branch information
sandrinegateau committed Sep 14, 2021
2 parents d1dd8f9 + b8633ad commit 8e3f1a1
Show file tree
Hide file tree
Showing 24 changed files with 81 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/iotMapManager/css/map.css
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion src/iotMapManager/css/markers.css
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion src/iotMapManager/css/popup.css
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion src/iotMapManager/css/tabs.css
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion src/iotMapManager/import_png.d.ts
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion src/iotMapManager/index.ts
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion src/iotMapManager/iot-map-manager.css
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion src/iotMapManager/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 2 additions & 1 deletion src/iotMapManager/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# IotMapManager V2.6.2
# IotMapManager V2.6.5

This library provides management of markers dedicated to projects using mapping.
## use
Expand Down Expand Up @@ -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.



Expand Down
2 changes: 1 addition & 1 deletion src/iotMapManager/src/iot-map-area-manager.ts
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion src/iotMapManager/src/iot-map-area.ts
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down
7 changes: 2 additions & 5 deletions src/iotMapManager/src/iot-map-cluster-manager.ts
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down Expand Up @@ -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]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/iotMapManager/src/iot-map-cluster.ts
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion src/iotMapManager/src/iot-map-common-svg.ts
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion src/iotMapManager/src/iot-map-config.ts
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down
4 changes: 2 additions & 2 deletions src/iotMapManager/src/iot-map-icons.ts
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down Expand Up @@ -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) ? `<div class='iotmap-cluster-big-popup'>` : `<div class='iotmap-cluster-popup'>`

Expand Down
19 changes: 11 additions & 8 deletions src/iotMapManager/src/iot-map-manager.ts
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down Expand Up @@ -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
Expand All @@ -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))
}
Expand Down Expand Up @@ -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()
}

/**
Expand All @@ -278,15 +281,15 @@ 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)
}

/**
* 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)
}

Expand Down
8 changes: 2 additions & 6 deletions src/iotMapManager/src/iot-map-marker-manager.ts
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down Expand Up @@ -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]
}
}

Expand Down
41 changes: 40 additions & 1 deletion src/iotMapManager/src/iot-map-marker.ts
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}
}
2 changes: 1 addition & 1 deletion src/iotMapManager/src/iot-map-path-manager.ts
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion src/iotMapManager/src/iot-map-path.ts
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down
6 changes: 5 additions & 1 deletion src/iotMapManager/src/iot-map-types.ts
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/iotMapManager/src/iot-map-user-marker-manager.ts
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion src/iotMapManager/src/iot-map-user-marker.ts
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down

0 comments on commit 8e3f1a1

Please sign in to comment.