Class: LeafletView

LeafletView(propertiesopt)

This class is in charge of displaying GPS/orientation data by adding a marker to the Leaflet Map object.

Constructor

new LeafletView(propertiesopt)

Create a View.
Parameters:
Name Type Attributes Default Description
properties Object <optional>
{} the properties of the view
Properties
Name Type Attributes Default Description
container String The div element to attach to
layers Array.<Object> <optional>
[] The initial layers to add
autoZoomOnFirstMarker Boolean <optional>
false auto zoom on the first added marker
follow Boolean <optional>
false follow the marker
initialView Object <optional>
Sets the view of the map (geographical center and zoom) with the given animation options. See details
overlayLayers Array.<Object> <optional>
L.tileLayer objects to use as overlay layer
baseLayers Array.<Object> <optional>
L.tileLayer objects to use as base layer
Source:
Example
import LeafletView from 'core/ui/view/map/LeafletView.js';

 let leafletMapView = new LeafletView({
	container: 'leafletMap',
	layers: [
	  new PointMarkerLayer({
      dataSourceId: gpsDataSource.id,
      getLocation: (rec) => ({
        x: rec.location.lon,
        y: rec.location.lat,
        z: rec.location.alt
      }),
      icon: './images/car-location.png',
      iconSize: [32, 64],
      iconAnchor: [16, 65],
      name: 'Car',
      description: 'GPS car Toulouse'
    })
  ],
	autoZoomOnFirstMarker: true
});

Extends

Methods

(protected) addEllipseToLayer(layer, ellipseObject)

Associate a ellipseId to a Layer for a fast lookup
Parameters:
Name Type Description
layer Ellipse.props the Layer object
ellipseObject Object the Map ellipse object
Overrides:
Source:

addLayer(layer)

Adds a layer to the view. A broadcastChannel is going to listen the new dataSources
Parameters:
Name Type Description
layer Layer The layer object
Overrides:
Source:

addMarker(properties) → {Object}

Add a marker to the map.
Parameters:
Name Type Description
properties PointMarkerLayer.properties the layer properties
Source:
Returns:
the the new created marker
Type
Object

(protected) addMarkerToLayer(layer, markerObject)

Associate a markerId to a Layer for a fast lookup
Parameters:
Name Type Description
layer PointMarkerLayer.props the Layer object
markerObject Object the Map marker object
Overrides:
Source:

addPolyline(locations, properties) → {string}

Add a polyline to the map.
Parameters:
Name Type Description
locations locations the coordinates [{x, y}]
properties Object
Properties
Name Type Description
color String
weight Number
opacity Number
smoothFactor Number
Source:
Returns:
the id of the new created polyline
Type
string

(protected) addPolylineToLayer(layer, polylineObject)

Associate a polylineId to a Layer for a fast lookup
Parameters:
Name Type Description
layer Polyline.props the Layer object
polylineObject Object the Map polyline object
Overrides:
Source:

attachTo(divId)

Attach the view to a specific div. If the view has already been attached to a div, it will be removed from its current parent and will be attached to new one. Note: the onResize() is called at the end of the process.
Parameters:
Name Type Description
divId String The div element to attach to
Overrides:
Source:

getDataSourcesId() → {Array.<String>}

Gets the list of the dataSource ids contained into the view.
Overrides:
Source:
Returns:
The list of dataSource ids
Type
Array.<String>

getDefaultLayers() → {Array}

Gets the list of default layers.
Source:
Returns:
Type
Array

getDivId() → {String}

Gets the div id of the DOM element.
Overrides:
Source:
Returns:
The div id of the view
Type
String

(protected) getEllipse(layer)

Get the ellipse associate to the Layer
Parameters:
Name Type Description
layer Ellipse.props the Layer Object
Overrides:
Source:

(protected) getEllipsoids()

Get all ellpsoids contained in this view
Overrides:
Source:

getId() → {String}

Gets the inner id of the view object.
Overrides:
Source:
Returns:
The id of the view
Type
String

getLayer(layerId) → {Layer}

Get the Layer associated to its id
Parameters:
Name Type Description
layerId String the id of the Layer
Overrides:
Source:
Returns:
- the corresponding layer, null otherwise
Type
Layer

getLayerId(id) → {null|String}

Gets the the Layer id from a concatenated id
Parameters:
Name Type Description
id String the concatenated such as layerId$markerId
Overrides:
Source:
Returns:
the Layer id
Type
null | String

(protected) getMarker(props)

Get the markerId associate to the Layer
Parameters:
Name Type Description
props PointMarkerLayer.props the Layer Object
Overrides:
Source:

getMarkerId(id) → {null|String}

Gets the the Marker id from a concatenated id
Parameters:
Name Type Description
id String the concatenated such as layerId$markerId
Overrides:
Source:
Returns:
the marker id
Type
null | String

(protected) getMarkers()

Get all markers contained in this view
Overrides:
Source:

(protected) getPolyline(layer)

Get the ellipse associate to the Layer
Parameters:
Name Type Description
layer Ellipse.props the Layer Object
Overrides:
Source:

(protected) getPolylines()

Get all polylines contained in this view
Overrides:
Source:

hide()

Hide the view
Overrides:
Source:

onMarkerHover(markerId, markerObject, layer, event)

Method to call onHover Layer method if exists
Parameters:
Name Type Description
markerId String the Layer markerId
markerObject Object the View marker object
layer PointMarkerLayer the Layer object
event Object the original Map View event
Overrides:
Source:

onMarkerLeftClick(markerId, markerObject, layer, event)

Method to call onLeftClick Layer method if exists
Parameters:
Name Type Description
markerId String the Layer markerId
markerObject Object the View marker object
layer PointMarkerLayer the Layer object
event Object the original Map View event
Overrides:
Source:

onMarkerMove(markerId, markerObject, layer, event)

Method to call onMove Layer method if exists
Parameters:
Name Type Description
markerId String the Layer markerId
markerObject Object the View marker object
layer PointMarkerLayer the Layer object
event Object the original Map View event
Overrides:
Source:

onMarkerRightClick(markerId, markerObject, layer, event)

Method to call onRightClick Layer method if exists
Parameters:
Name Type Description
markerId String the Layer markerId
markerObject Object the View marker object
layer PointMarkerLayer the Layer object
event Object the original Map View event
Overrides:
Source:

removeAllFromLayer(layer)

Remove Corresponding Layer
Parameters:
Name Type Description
layer Layer The layer object
Overrides:
Source:

removeAllFromLayers()

Removes all view item from the view.
Overrides:
Source:

removeEllipsoids(ellipse)

Remove the ellipsoids corresponding to a EllipseLayer Layer
Parameters:
Name Type Description
ellipse Ellipse the layer to remove the ellipsoids from
Overrides:
Source:

removeMarkerFromLayer(marker)

Abstract method to remove a marker from its corresponding layer. This is library dependant.
Parameters:
Name Type Description
marker Object The Map marker object
Overrides:
Source:

removeMarkers(layer)

Remove the markers corresponding to a PointMarker Layer
Parameters:
Name Type Description
layer PointMarkerLayer the layer to remove the markers from
Overrides:
Source:

removePolylineFromLayer(polyline)

Abstract method to remove a polyline from its corresponding layer. This is library dependant.
Parameters:
Name Type Description
polyline Object The Map polyline object
Overrides:
Source:

removePolylines(polyline)

Remove the polylines corresponding to a PolylineLayer Layer
Parameters:
Name Type Description
polyline Polyline the layer to remove the polylines from
Overrides:
Source:

reset()

Calls for resetting the view.
Overrides:
Source:

setData(dataSourceId, data)

Set the data to the view. Each view has to handle the kind of the data separately.
Parameters:
Name Type Description
dataSourceId String The dataSource id of the source providing the data
data Array.<any> The data array to set
Overrides:
Source:

show(properties)

Show the view.
Parameters:
Name Type Description
properties Object A generic object
Overrides:
Source:

updateMarker(props)

Updates the marker associated to the layer.
Parameters:
Name Type Description
props PointMarkerLayer.props The layer properties allowing the update of the marker
Source:

updatePolyline(props)

Updates the polyline associated to the layer.
Parameters:
Name Type Description
props PolylineLayer.props The layer properties allowing the update of the polyline
Source:

Events

beforeAddingItems

This method is called before attaching any view items passed as arguments in the constructor of the view.
Parameters:
Name Type Description
options Object A generic object to use
Overrides:
Source:

onResize

Callback called when the view is resized
Overrides:
Source: