Component Class

class BeastBytes\Yii\Leaflet\Component

A component of a Leaflet map

This class is for use by plugin developers; all plugins must extend this class

__construct(array $options)

Create a new component

Parameters:
  • $options (array<string, mixed>.) – Component options

Returns:

A new Component instance

Return type:

Component

addToMap(bool $addToMap) self

Determine whether the component is added to the map

The default is to add the component to the map

Parameters:
  • $addToMap (bool) – Whether to add the component to the map

Returns:

A new Component instance with addToMap

Return type:

Component

jsVar(string $jsVar)

Set the component’s JavaScript variable name

Parameters:
  • $jsVar (string) – The component’s JavaScript variable name

Returns:

A new Component instance with the component’s JavaScript variable name

Return type:

Component

getJsVar()

Get the component’s JavaScript variable name

If jsVar has not been called a variable name of the form \w+\d+ will be generated, where:

  • \w+ is the type of component - ‘control’ || ‘layer’ || ‘plugin’

  • \d+ is a unique number for the component type

Example: control1

Returns:

The component’s JavaScript variable name

Return type:

string