Create attribute "leaflet_id" for LayerGroups

Created on 21 February 2014, over 10 years ago
Updated 12 December 2023, 7 months ago

When a LayerGroup is created, then it gets a numerical id. Thus the layer containing all markers (for example) is not easily accessible in client-side Javascript.

A simple solution is to add the attribute 'leaflet_id' to the group feature when creating the the data structure of the map.

$features_group = array(
    'leaflet_id' => 'markers',
    'group' => 'markers',
    'label' => t('Markers'),
    'features' => $features,
);

In leaflet.drupal.js this attribute is recognized when creating the LayerGroup and the LayerGroup can be accessed, like in this example:

var markerLayer = Drupal.settings.leaflet[0].lMap._layers['markers']
✨ Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.69.0 2024