Add hook to give custom modules possibility to add other maps to default list.

Created on 20 October 2019, about 5 years ago
Updated 11 June 2024, 5 months ago

It would be a good idea to add another hook to give custom modules the possibility to add other maps to the default list displayed at /admin/config/system/leaflet_more_maps something like hook_leaflet_more_maps_default_map_list_alter(&$map_info)

Implementation example (Result in attached ScreenShot).

/**
 * Implements hook_leaflet_more_maps_default_map_list_alter().
 */
function MY_MODULE_leaflet_more_maps_default_map_list_alter(&$map_info) {
  // Use headless protocol rather than logic based on global $is_https.
  $prot = '//';
  // Assemble xyz used by openSeaMaps.
  $zxy = '{z}/{x}/{y}.png';
  $map_info['openseamaps'] = [
    'label'       => 'Open Sea Map',
    'description' => 'OpenSeaMaps Layer',
    'settings'    => [
      'attributionControl' => TRUE,
      'closePopupOnClick'  => TRUE,
      'doubleClickZoom'    => TRUE,
      'dragging'           => TRUE,
      'fadeAnimation'      => TRUE,
      'layerControl'       => TRUE,
      'maxZoom'            => 18,
      'minZoom'            => 1,
      'scrollWheelZoom'    => TRUE,
      'touchZoom'          => TRUE,
      'trackResize'        => TRUE,
      'zoomAnimation'      => TRUE,
      'zoomControl'        => TRUE,
    ],
    'layers'      => [
      'earth'   => [
        'urlTemplate' => $prot . '{s}.tile.openstreetmap.org/' . $zxy,
        'options'     => [
          'attribution' => "Map data &copy; <a href='http://openstreetmap.org'>OSM Mapnik</a>",
          'subdomains'  => [
            0 => 'a',
            1 => 'b',
            2 => 'c',
          ],
        ],
      ],
      'seamark' => [
        'urlTemplate'  => $prot . 'tiles.openseamap.org/seamark/' . $zxy,
        'isBaseLayer'  => FALSE,
        'layerControl' => TRUE,
        'options'      => [
          'attribution' => "Map data &copy; <a href='http://openseamap.org'>Open Sea Maps</a>",
          'subdomains'  => [
            0 => 'a',
            1 => 'b',
            2 => 'c',
          ],
        ],
      ],
    ],
  ];
}
Feature request
Status

Fixed

Version

2.1

Component

Code

Created by

🇫🇷France berramou

Live updates comments and jobs are added and updated live.
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.

Production build 0.71.5 2024