Class: MapBase

(abstract) MapBase(…args)

MapBase Each instance represents the map object itself, and adds all necesary listeners and object specified in the given configuration. This class is the core of the module, and will create instances of all the other objects, including the native maps implemented by inheriting classes.

Constructor

(abstract) new MapBase(…args)

MapBase constructor
Parameters:
Name Type Attributes Description
args Array <repeatable>
List of arguments to be sent to State constructor
Source:

Members

(static) CONTROLS

List of controls that maybe shown inside the rendered map.
Source:

(static) CONTROLS_MAP

Control mapping that should be overriden by child classes.
Source:

(static) DialogImpl

Class that will be used for creating dialog objects.
Source:

(static) GeocoderImpl

Class that will be used for parsing geoposition information.
Source:

(static) GeoJSONImpl

Class that will be used for creating GeoJSON instances. This class must be replaced by another one extending GeoJSONBase.
Source:

(static) MarkerImpl

Class that will be used for creating map markers. This class must be replaced by another one extending MarkerBase.
Source:

(static) POSITION

Available map positions.
Source:

(static) POSITION_MAP

Position mapping that should be overriden by child classes.
Source:

(static) SearchImpl

Class that will be used for creating an instance of searchbox. This class must be replaced by another one extending MarkerBase.
Source:

(static, non-null) STATE :Object

State definition.
Type:
  • Object
Source:

Methods

(static) get(id, callback)

Registers the given callback to be executed when the map identified by the given id has been created. If the map has already been created, it is executed immediatly.
Parameters:
Name Type Description
id string Id of the map that needs to be created
callback function Callback being executed
Source:

(static) register(id, map, portletId)

Registers the given map with the given id, and executes all existing callbacks associated with the id. Then it clears the list of callbacks.
Parameters:
Name Type Description
id string Id of the map that has been created
map Object Map that has been created
portletId string Id of the portlet that registers the map
Source:

(protected) _bindUIMB()

Source:
See:
  • this._geoJSONLayer
  • this._geolocationMarker
  • this._customControls All added listeners are implemented as binded methods:
  • this._handleGeoJSONLayerFeaturesAdded
  • this._handleGeoJSONLayerFeatureClicked
  • this._handleGeoLocationMarkerDragended
  • this._handleHomeButtonClicked
  • this._handleSearchButtonClicked

(protected) _createCustomControls()

Creates existing custom controls and stores them inside _customControls. It only adds the home button and the search box if the corresponding flags are activated inside MapBase.controls.
Source:

(abstract, protected) _createMap(location, controlsConfig) → {Object}

Creates a new map for the given location and controlsConfig.
Parameters:
Name Type Description
location Object
controlsConfig Object
Source:
Returns:
Created map
Type
Object

(protected) _getControlsConfig() → {Object}

Returns an object with the control configuration associated to the existing controls (MapBase.controls).
Source:
Returns:
Object with the control options with the following shape: for each control, there is a corresponding [control] attribute with a boolean value indicating if there is a configuration for the control. If true, where will be a [control]Options attribute with the configuration content.
Type
Object

(protected) _getDialog() → {MapBase.DialogImpl|null}

If there is an existing this._dialog, it returns it. Otherwise, if the MapBase.DialogImpl class has been set, it creates a new instance with the existing map and returns it.
Source:
Returns:
Type
MapBase.DialogImpl | null

(protected) _getGeocoder() → {MapBase.GeocoderImpl|null}

If there is an existing this._geocoder, it returns it. Otherwise, if the MapBase.GeocoderImpl class has been set, it creates a new instance and returns it.
Source:
Returns:
Type
MapBase.GeocoderImpl | null

(protected) _handleGeoJSONLayerFeatureClicked(param0)

Event handler executed when a GeoJSONLayer feature is clicked. It simple propagates the event with the given feature.
Parameters:
Name Type Description
param0 Object Feature to be propagated.
Source:

(protected) _handleGeoJSONLayerFeaturesAdded(param0)

Event handler executed when any feature is added to the existing. GeoJSONLayer. It will update the current position if necesary.
Parameters:
Name Type Description
param0 Object Array of features that will be processed.
Source:
See:
  • MapBase.getBounds()
  • MapBase.position

(protected) _handleGeoLocationMarkerDragended(param0)

Event handler executed when the geolocation marker has been dragged to a new position. It updates the instance position.
Parameters:
Name Type Description
param0 Object New marker location.
Source:
See:
  • MapBase._getGeoCoder()
  • MapBase.position

_handleHomeButtonClicked(event)

Event handler executed when the home button GeoJSONLayer feature is clicked. It resets the instance position to _originalPosition and stops the event propagation.
Parameters:
Name Type Description
event Event Click event.
Source:
See:
  • MapBase.position
  • MapBase._originalPosition

_handlePositionChanged(param0)

Event handler executed when the user position changes. It centers the map and, if existing, updates the _geolocationMarker position.
Parameters:
Name Type Description
param0 Object New location information.
Source:
See:
  • MapBase.setCenter()
  • MapBase._geolocationMarker

_handleSearchButtonClicked(param0)

Event handler executed when the search button GeoJSONLayer feature has been clicked. It updates the instance position.
Parameters:
Name Type Description
param0 Object New position.
Source:
See:
  • MapBase.position

(protected) _initializeGeoJSONData()

If this.data has a truthy value and this._geoJSONLayer has been set, it tries to parse geoJSON information with _geoJSONLayer.addData()
Source:
See:
  • this._geoJSONLayer
  • this.data

(protected) _initializeLocation(location)

Initializes the instance map using the given location and, if this.geolocation property is true, tries to get the location using the geocoder.
Parameters:
Name Type Description
location Object Location object user for map initialization.
Source:
See:
  • this._initializeMap()
  • this._getGeocoder()

(protected) _initializeMap(position)

Creates a new map with the given position and initialize the map controls, loads the geoJSONData and, if geolocation is active, creates a marker for it.
Parameters:
Name Type Description
position Object Initial position added to the map.
Source:
See:
  • MapBase._getControlsConfig()
  • MapBase._createMap()
  • MapBase.GeoJSONImpl
  • MapBase.addMarker()
  • MapBase._createCustomControls()
  • MapBase._bindUIMB()
  • MapBase._initializeGeoJSONData()

addControl(control, position)

Adds a new control to the interface at the given position.
Parameters:
Name Type Description
control Object Native control object
position MapBase.POSITION Position defined in MapBase class
Source:

addMarker(location) → {MapBase.MarkerImpl}

If the class MapBase.MarkerImpl has been specified, creates an instance of this class with the given location and the existing this._map object and returns it.
Parameters:
Name Type Description
location Object Location object used for the marker position
Source:
Returns:
Type
MapBase.MarkerImpl

destructor()

Destroys the existing _geoJSONLayer and _customControls[SEARCH]
Source:
See:
  • MapBase._initializeMap()
  • MapBase._createCustomControls()

(abstract) getBounds() → {Object}

Returns the map bounds.
Source:
Returns:
Map bounds
Type
Object

getNativeMap() → {Object}

Returns the stored map
Source:
See:
  • MapBase._initializeMap()
Returns:
Type
Object

on(eventName, callback, contextopt) → {*}

Adds a listener for the given event using the given context. This methods uses MetalJS' functionality, but overrides the context binding in order to avoid breaking changes with the old implementation.
Parameters:
Name Type Attributes Description
eventName string Event name that will be listened.
callback function Callback executed when the event fires.
context Object <optional>
Optional context that will be used for binding the callback when specified.
Source:
See:
  • State.on
Returns:
Result of the State.on method.
Type
*

openDialog(dialogConfig)

Opens a dialog if this_getDialog() returns a valid object.
Parameters:
Name Type Description
dialogConfig * Dialog configuration that will be sent to the dialog.open() method.
Source:
See:
  • MapBase._getDialog()

(abstract) setCenter(location)

Centers the map on the given location.
Parameters:
Name Type Description
location Object
Source:

setPosition(position) → {Object}

Setter called everytime the position attribute is changed.
Parameters:
Name Type Description
position Object New position
Source:
Returns:
The given position object
Type
Object