Skip to content

Commit

Permalink
*** Version V0.2.4 ***
Browse files Browse the repository at this point in the history
  • Loading branch information
sgateau committed Nov 16, 2020
1 parent c4c8ad5 commit d077792
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 113 deletions.
14 changes: 14 additions & 0 deletions src/iotMapManager/iotMapManager.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/*
* Software Name : IotMapManager
* Version: 0.2.4
* SPDX-FileCopyrightText: Copyright (c) 2020 Orange
* SPDX-License-Identifier: MIT
*
* This software is distributed under the MIT License,
* the text of which is available at https://github.com/Orange-OpenSource/IOT-Map-Component/blob/master/LICENSE
* or see the "license.txt" file for more details.
*
* Author: S. Gateau
* Software description: provide markers, tabs, clusters and paths dedicated to iot projects using mapping
*/

/* iotMapManager.css */
.jauge {
transform: rotate(0deg);
Expand Down
50 changes: 0 additions & 50 deletions src/iotMapManager/iotMapManager.json

This file was deleted.

18 changes: 10 additions & 8 deletions src/iotMapManager/iotMapManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Software Name : IotMapManager
* Version: 0.2.3
* Version: 0.2.4
* SPDX-FileCopyrightText: Copyright (c) 2020 Orange
* SPDX-License-Identifier: MIT
*
Expand All @@ -15,8 +15,8 @@
import * as L from 'leaflet';
import 'leaflet.markercluster';
import { IotMapMarkers } from './iotMapMarkers/iotMapMarkers';
import * as config from './iotMapManager.json';
import * as commonSvg from './iotMapMarkers/iotMapCommonSvg';
import { IotMapManagerConfig } from './iotMapManagerConfig';
import { IotMapCommonSvg } from './iotMapMarkers/iotMapCommonSvg';

export class IotMapManager {
map: any;
Expand All @@ -40,13 +40,15 @@ export class IotMapManager {
// ------------------------------------------------------------------------------------------------------------------
init(selector) {
// init map
this.map = L.map(selector).setView(L.latLng(config.map.DEFAULT_LAT, config.map.DEFAULT_LON), config.map.DEFAULT_ZOOM_LEVEL);
this.map = L.map(selector).setView(
L.latLng(IotMapManagerConfig.map.DEFAULT_LAT, IotMapManagerConfig.map.DEFAULT_LON),
IotMapManagerConfig.map.DEFAULT_ZOOM_LEVEL);

// init base layers
const defaultLayer = L.tileLayer(config.map.openStreetMapLayer, {
const defaultLayer = L.tileLayer(IotMapManagerConfig.map.openStreetMapLayer, {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(this.map);
const geoportailLayer = L.tileLayer.wms(config.map.geoportailLayer, {
const geoportailLayer = L.tileLayer.wms(IotMapManagerConfig.map.geoportailLayer, {
attribution: '<a target="_blank" href="https://www.geoportail.gouv.fr/">Geoportail France</a>',
format: 'image/jpeg',
styles: 'normal'
Expand Down Expand Up @@ -300,7 +302,7 @@ export class IotMapManager {
// ------------------------------------------------------------------------------------------------------------------
defineClusterIcon(cluster) {
const childCount = cluster.getChildCount();
const size = config.cluster.iconSize;
const size = IotMapManagerConfig.cluster.iconSize;


// marker Distribution
Expand All @@ -324,7 +326,7 @@ export class IotMapManager {
if (tabDistribution[color]) {
const n = tabDistribution[color];
arc = n * 1193 / childCount - (60 / childCount); // todo I DON'T KNOW WHY !!!
svgGauge += commonSvg.circleGauge + `stroke='` + color
svgGauge += IotMapCommonSvg.circleGauge + `stroke='` + color
+ `' stroke-dasharray='` + arc + `, 1193' transform='rotate(` + angle + ` 225 225)'/>`;
angle += n * 360 / childCount;
}
Expand Down
67 changes: 67 additions & 0 deletions src/iotMapManager/iotMapManagerConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Software Name : IotMapManager
* Version: 0.2.4
* SPDX-FileCopyrightText: Copyright (c) 2020 Orange
* SPDX-License-Identifier: MIT
*
* This software is distributed under the MIT License,
* the text of which is available at https://github.com/Orange-OpenSource/IOT-Map-Component/blob/master/LICENSE
* or see the "license.txt" file for more details.
*
* Author: S. Gateau
* Software description: provide markers, tabs, clusters and paths dedicated to iot projects using mapping
*/

export class IotMapManagerConfig {
static map: any = {
DEFAULT_LAT: 44.8888929,
DEFAULT_LON: 4.8849108,
DEFAULT_ZOOM_LEVEL: 15,
CLUSTER_SIZE: 75,
// tslint:disable-next-line:max-line-length
geoportailLayer: 'https://wxs.ign.fr/{apikey}/geoportail/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&STYLE={style}&TILEMATRIXSET=PM&FORMAT={format}&LAYER=ORTHOIMAGERY.ORTHOPHOTOS&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}',
openStreetMapLayer: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
};

static markers: any = {
default: {
shape: 'circle',
color: 'black',
anchored: true,
plain: true
},
size: {
fullSvgWidth: 100,
fullSvgHeight: 100,
unselectedSvgWidth: 44,
unselectedSvgHeight: 44,
selectedSvgWidth: 64,
selectedSvgHeight: 64,
anchorHeight: 10
},

circles: {
borderColor: 'white',
backgroundColor: 'white'
},

square: {
borderColor: 'white',
backgroundColor: 'white'
},

poi: {
borderColor: 'white'
}
};

static cluster: any = {
iconSize: 64,
circleLayer: {
},
squareLayer: {
},
poiLayer: {
}
};
}
22 changes: 11 additions & 11 deletions src/iotMapManager/iotMapMarkers/iotCircleMarker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Software Name : IotMapManager
* Version: 0.2.3
* Version: 0.2.4
* SPDX-FileCopyrightText: Copyright (c) 2020 Orange
* SPDX-License-Identifier: MIT
*
Expand All @@ -12,8 +12,8 @@
* Software description: provide markers, tabs, clusters and paths dedicated to iot projects using mapping
*/

import * as commonSvg from './iotMapCommonSvg';
import * as config from '../iotMapManager.json';
import { IotMapCommonSvg} from './iotMapCommonSvg';
import { IotMapManagerConfig } from '../iotMapManagerConfig';

export class IotCircleMarker {

Expand All @@ -30,12 +30,12 @@ export class IotCircleMarker {
const height = (selected) ? 64 : 44;

// border color
const borderColor = (selected) ? marker.shape.color : config.markers.circles.borderColor;
const borderColor = (selected) ? marker.shape.color : IotMapManagerConfig.markers.circles.borderColor;

// center color
const svgCenter = (marker.shape.plain)
? `<path fill='` + marker.shape.color + `' ` + commonSvg.circleCenter + `/>`
: `<path fill='` + config.markers.circles.backgroundColor + `' ` + commonSvg.circleCenter + `/>`;
? `<path fill='` + marker.shape.color + `' ` + IotMapCommonSvg.circleCenter + `/>`
: `<path fill='` + IotMapManagerConfig.markers.circles.backgroundColor + `' ` + IotMapCommonSvg.circleCenter + `/>`;

if (marker.inner) {
// label
Expand All @@ -61,19 +61,19 @@ export class IotCircleMarker {
// gauge
if (marker.gauge) {
const arc = marker.gauge.percent * 1193 / 100;
svgGauge = commonSvg.circleGauge + `stroke='` + marker.gauge.color + `' stroke-dasharray='`
svgGauge = IotMapCommonSvg.circleGauge + `stroke='` + marker.gauge.color + `' stroke-dasharray='`
+ arc + `, 1193' transform='rotate(-90 225 225)'/>`;
}

// build shape
const border = `<path fill='` + borderColor + `' `
+ ((marker.shape.anchored)
? commonSvg.circleAnchoredBorder
: commonSvg.circleBorder) + `/>`;
? IotMapCommonSvg.circleAnchoredBorder
: IotMapCommonSvg.circleBorder) + `/>`;
const innerColor = `<path fill='` + marker.shape.color + `' `
+ ((marker.shape.anchored)
? commonSvg.circleAnchoredInnerColor
: commonSvg.circleInnerColor) + `/>`;
? IotMapCommonSvg.circleAnchoredInnerColor
: IotMapCommonSvg.circleInnerColor) + `/>`;

// result
return `<svg xmlns='http://www.w3.org/2000/svg' width='` + width + `' height='` + height + `' viewBox='0 0 450 545'>`
Expand Down
Loading

0 comments on commit d077792

Please sign in to comment.