Map

class BeastBytes\Yii\Leaflet\Map

A Leaflet map

__construct(AssetManager $assetManager, private WebView $webView)

Create a new Map instance

Returns:

A new Map instance

Return type:

Map

addAttributes(array $valuesMap)

Add HTML attributes for the container tag

Returns:

A new Map instance with the HTML attributes added

Return type:

Map

addClass(string ...$value)

Add classes to the container tag

Parameters:
  • ...$value (string) – The class(es) to add

Returns:

A new Map instance with the class(es) added

Return type:

Map

addControls(Control ...$controls)

Add controls to the map

Parameters:
  • ...$control (Control) – The control(s) to add

Returns:

A new Map instance with control(s) added

Return type:

Map

addLayers(array $layers)

Add layers to the map

Parameters:
  • $layers (array[string=>Layer]) – The layer(s) to add where the keys are the layer names

Returns:

A new Map instance with the layer(s) added

Return type:

Map

addPlugins(Component ...$plugins)

Add plugins to the map

Parameters:
  • ...$plugins (Component) – The plugin(s) to add

Returns:

A new Map instance with the plugin(s) added

Return type:

Map

attributes(array $valuesMap)

Set the HTML attributes for the container tag

Return type:

Map

getId()

Return the map HTML ID

Returns:

The map HTML ID

Return type:

string

getLeafletVar()

Return the map Leaflet variable name

Returns:

The map Leaflet variable name

Return type:

string

id(string $value)

Set the map widget HTML ID

Parameters:
  • $id (string) – The map widget HTML ID

Returns:

A new Map instance with the map widget HTML ID

Return type:

Map

leafletVar(string $leafletVar)

Set the map Leaflet variable name

Parameters:
  • $leafletVar (string) – The Leaflet variable name

Returns:

A new Map instance with the Leaflet variable name

Return type:

Map

options(array $options)

Set the map options

Parameters:
  • array[string=>mixed] – The map options

Returns:

A new Map instance with the map options added

Return type:

Map

render()

Render the map HTML and register the Leaflet JavaScript

Returns:

The map HTML

Return type:

string

tag(string $tag)

Set the container tag containing the map

Default div

Parameters:
  • $tag (string) – The container tag

Returns:

A new Map instance with the container tag

Return type:

Map