0.0.34 • Published 3 years ago

iotmapmanager-test v0.0.34

Weekly downloads
6
License
MIT
Repository
github
Last release
3 years ago

IotMapManager V2.6.5

This library provides management of markers dedicated to projects using mapping.

use

In your project file (except IotMapManager and IotMapConf, all are optionnal):

import {
  IotMapManager,
  IotCluster,
  IotMarker,
  IotUserMarker,
  IotPath,
  IotArea,
  ShapeType,
  IotMapConfig,
  TabType,
  IotMapMarkerManager,
  IotMapClusterManager,
  IotMapUserMarkerManager,
  IotMapPathManager,
  IotMapAreaManager
} from 'iotmapmanager'

and instanciate classes you need:

conf: IotMapConfig = new IotMapConfig();    // mandatory
commonIotMap: IotMapManager = new IotMapManager(this.conf) // mandatory

iotMapMarkerManager: IotMapMarkerManager = new IotMapMarkerManager(this.commonIotMap, this.conf)
iotMapClusterManager: IotMapClusterManager = new IotMapClusterManager(this.commonIotMap, this.conf)
otMapUserMarkerManager: IotMapUserMarkerManager = new IotMapUserMarkerManager(this.commonIotMap, this.conf)
iotMapPathManager: IotMapPathManager = new IotMapPathManager(this.commonIotMap, this.conf)

In your css file:

@import 'iotmapmanager/iotMapManager.css'; 

If your use TypeScript, all types are defined in lib/index.d.ts

marker definition

A marker is defined as follow:

{
    id: string
    location: Location
    layer?: string
    popup?: Popup
    tab?: Tab
    shape?: Shape
    inner?: Inner
    template?: string
    status?: string
}
ParamTypeOptionnalComment
idstringnoUsed by update and remove functions
locationLocationnon(lat, lng) of the marker
layerstringyesyou can sort your markers in different layers. A tool allow you to display specific layers (see configuration)
popupPopupyesa string displayed in a popup when marker is clicked.
tabTabyesa little white rectangle displayed above the marker. It contains few characters or icon
shapeShapeyesall information relative to marker shape
innerInneryesall information relative to marker inner
statusstringyesname of the status to apply (see configuration)
templatestringyesname of the template to apply (see configuration)

manual clusters definition

{
  id: string
  location: Location
  layer?: string
  contentLabel: string
  childCount: number
  colNumber?: number
  aggregation: {
    singularState: string
    pluralState: string
    count: number
    color: string
    bullet?: string
    url?: string
    urlTarget?: string
  }[]
}
ParamtypeoptionnalComment
idstringnoused for update/removeMarker purposes
locationLocationno(lat, long) of the cluster
layerstringyesYou can sort your manual clusters in different layers. A tool allow you to display specific layers (see configuration)
contentLabelstringnowhat is clustered ? (devices, cars, buildings...)
childCountnumbernonumber of clustered elements
colNumbernumberyesnumber of columns displayed in a cluster popup
aggregationarraynocontaining following info for each type of element

Aggregation :

ParamtypeoptionnalComment
singularStatestringnoused for only one element
pluralStatestringnoused for several elements
countnumbernonumber of elements
colorstringnocolor to display is gauge and popup
bulletstringyesbullet used to illustrate current state (plain circle if not specified)
urlstringyesstate name is then displayed as an hyper link with 'url' as href
urlTargetstringyesspecifies where to open the linked document or page ('_blank', '_self', '_parent', '_top', framename)

user marker definition

{
    location: Location
    direction?: number (0-360)
    accuracy?: number (in meters)
}
ParamtypeoptionnalComment
locationLocationnoposition of the user marker on the map
directionnumberyesangle in degrees, clockwise
accuracynumberyesradius in meters of accuracy area around the user marker

path definition

{
  id: string
  color?: string
  points: Location[]
  positions?: Location[]
  additional?: {
    points: Location[]
    color: string
    line: number
  }[]
}
ParamtypeoptionnalComment
idstringnoused for update and remove
colorstringyescolor of the path
pointsLocation arraynoarray of geographical points defining the path
positionsLocation arrayyesallow to display intermediate markers along the path
additionalarray of additional pathyesallow to display additional sub paths along the main path

additional path :

ParamtypeoptionnalComment
pointsLocation arraynoarray of geographical points defining the path
colorstringyescolor of the path
linenumber (1..4)nodefine the place of the sub path (1 is full left, 4 is full right)

area definition

{
  id: string
  points: Location[]
  color?: string
  fillColor?: string
  fillOpacity?: number
}
ParamtypeoptionnalComment
idstringnoused for update and remove
pointsLocation arraynoarray of geographical points defining the area. Last and first are link, no need to duplicate
colorstringyesborder color of the area
fillColorstringyesinterior color of the area
fillOpacitystringyesinterior color opacity of the area

enums

enum ShapeType { circle, square }
enum TabType { normal, large }
enum PathIconType { start, mid, end }

Common interfaces definitions

Location

interface Location {
  lat: number
  lng: number
}

GeolocMarker

interface GeolocMarker {
  location: Location
}

Popup

interface Popup {
  title?: string
  body?: string
}

Tab

interface Tab {
  content: string
  type?: TabType
}

Shape

interface Shape {
 type?: ShapeType
 anchored?: boolean
 plain?: boolean
 color?: string
 percent?: number (0-100)
 accuracy?: number (in meters)
 direction?: number (0-360)
}

Inner

interface Inner {
  color?: string

  icon?: string
  // *** OR ***
  label?: string
}

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.

Configuration

Default values are set for configuration. You must instanciate a configuration for each map:

config = new IotMapConfig();

You can modify several values by calling :

IotMapConfig.setConfig(...)

Editable values :

  • map:

    • defaultLat: map center latitude
    • defaultLng: map center longitude
    • defaultZoomLevel: zoom level
    • defaultLayerName: layer name if no layer specified in marker info
    • clusterRadius: radius used to cluster markers
    • externalClustering: if true, auto clustering is deactivated. You need to calculate your own clusters
    • layerControl: if true, display a tool in top right corner to manage layers display,
    • exclusiveLayers: if true, you can display only one layer at a time, if false, all layers can be displayed simultaneously
  • markers:

    • default:

      • shape: shape used if no shape is specified in marker info
      • inner: color of the marker inner
  • markerStatus:
    • for each status (defined by a name as string):

      • name:
        • singular: name used in cluster popup if there is only one element with this status
        • plural: name used in cluster popup if there are several elements with this status
      • layer (optionnal): you can sort your markers in different layers. A tool allow you to display specific layers (see configuration)
      • popup (optionnal) is a string displayed in a popup when marker is clicked. (see Popup)
      • tab (optionnal) is a little white rectangle displayed above the marker. It contains few characters or icon (see Tab)
      • shape (optionnal): all information relative to marker shape (see shape)
      • inner (optionnal) : all information relative to marker inner (see Inner)
      • bullet (optionnal) is the bullet displayed before the name status in cluster popups (html code)
      • url (optionnal): if defined, in the cluster popup the name becomes an hyperlink with 'url' as href
      • urlTarget specifies where to open the linked document or page ('_blank', '_self', '_parent', '_top', framename)
  • markerTemplate: agregates all display parameters (colors, shape, icon...)

    • for each template (defined by a name as string):
      • layer (optionnal): you can sort your markers in different layers. A tool allow you to display specific layers (see configuration)
      • popup (optionnal) is a string displayed in a popup when marker is clicked. (see Popup)
      • tab (optionnal) is a little white rectangle displayed above the marker. It contains few characters or icon (see Tab)
      • shape (optionnal): all information relative to marker shape (see shape)
      • inner (optionnal) : all information relative to marker inner (see Inner)
  • accuracyCircle: default parameters for accuracy area

    • layerName: name displayed in layers control list
    • color: default border color for accuracy circles
    • fillColor: default fill color for accuracy circles
    • fillOpacity: interior color opacity for accuracy circles
  • layerTemplate: parameters that can be applied to a layer

    • for each template (defined by a name as string):
      • content (optionnal): the html code to display in cluster tab (can be img, text...)
      • type (optionnal): the type used for cluster tab (see )
      • popupColNumber (optionnal): number of columns to display in cluster popup
  • clusters

    • defaultColor: color used if marker has no status, then no status color
  • userMarker

    • layerName: name displayed in layers control list
  • path

    • layerName: name displayed in layers control list
    • color: default path color
    • width: path width in px
  • area

    • layerName: name displayed in layers control list
    • color: default border color for areas
    • fillColor: default fill color for areas
    • fillOpacity: interior color opacity for areas

Marker data are applied first,

  • then default values if needed,
  • then template if one,
  • then status if one

Managers

IotMapManager

This class manager the map and every relying to the map:

  • layers and there display tool,
  • automatic or manual clustering,
  • events

IotMapMarkerManager

This class manages markers:

  • addMarker / addMarkers: adds a (list of) marker(s) to the map
  • removeMarker / removeMarkers: removes a (list of) marker(s) from the map
  • updateMarker: updates specified marker by applying partial IotMarker data
  • updateAllMarkers:
    • adds non existing markers
    • removes existing markers not present in the new list
    • updates existing markers present in the new list
  • getMarker: returns the L.Marker corresponding to the specified id
  • getAllMarkers: returns all L.Marker present in the map
  • redrawAll: forces all markers to redraw

IotMapMarkerManager requires a configuration object and an IotMapManager

IotMapClusterManager

This class manages manual clusters:

  • addCluster / addClusters: adds a (list of) cluster(s) to the map
  • removeCluster / removeClusters: removes a (list of) Cluster(s) from the map
  • updateCluster: updates specified Cluster by applying partial IotCluster data
  • updateAllCluster:
    • adds non existing Cluster
    • removes existing Cluster not present in the new list
    • updates existing Cluster present in the new list
  • redrawAll: forces all Cluster to redraw

IotMapClusterManager requires a configuration object and an IotMapManager

IotMapUserMarkerManager

This class manages user marker: (!! only one user marker at a time)

  • addUserMarker: adds the userMarker to the map
  • removeUserMarker: removes the userMarker from the map
  • updateUserMarker: updates the userMarker
  • getUserMarker: returns the L.Marker corresponding to the userMarker

IotMapUserMarkerManager requires a configuration object and an IotMapManager

IotMapPathManager

This class manages paths:

  • addPath/ addPaths: adds a (list of) path(s) to the map
  • removePath / removePaths: removes a (list of) path(s) from the map

IotMapPathManager requires a configuration object and an IotMapManager

IotMapAreaManager

This class manages areas:

0.0.34

3 years ago

0.0.33

3 years ago

0.0.32

4 years ago

0.0.30

4 years ago

0.0.31

4 years ago

0.0.23

4 years ago

0.0.24

4 years ago

0.0.25

4 years ago

0.0.26

4 years ago

0.0.29

4 years ago

0.0.22

4 years ago

0.0.20

4 years ago

0.0.21

4 years ago

0.0.19

4 years ago

0.0.18

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.13

4 years ago

0.0.14

4 years ago

0.0.15

4 years ago

0.0.16

4 years ago

0.0.17

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago