How to represent a point on the map?

Created on 11 March 2024, 9 months ago
Updated 15 March 2024, 9 months ago

Problem/Motivation

In version 2.2.12 of this module you could mark one or more points on the map as follows:

    $features = [
      [
        'type' => 'point',
        'lat' => -31.7455000,
        'lon' => -60.5218700,
        'popup' => '<h1>Hello from Paraná</h1>',
      ]
    ];
    $element['#map'] = \Drupal::service('leaflet.service')->leafletRenderMap($map, $features, $map_height);

I updated the module to the latest version (10.2.12) and the points stopped showing.
What am I doing wrong?
Where can I find documentation, examples or more information about the features?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Closed: works as designed

Version

10.2

Component

Documentation

Created by

🇦🇷Argentina abelpzl

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @abelpzl
  • Status changed to Closed: works as designed 9 months ago
  • 🇦🇷Argentina abelpzl

    My problem was fixed by adding zoomControlPosition => topleft in the definition of my HOOK_leaflet_map_info().

    function my_module_leaflet_map_info() {
      return [
          'my_map' => [
            'label' => 'My Argentine map',
            'description' => t('...'),
            'settings' => [
              // ...
              'zoomControlPosition' => 'topleft',
              // ...
            ],
          ],
          'layers' => [ ... ],
          'plugins' => [ ... ],
        ],
      ];
    }
    

    The following code works correctly in my case and marks three points on my map

    $map_features = [
      0 => [
        'type' => 'point', 
        'lon' => '-60.292969', 
        'lat' => '-36.315125'
      ],
      1 => [
        'type' => 'point', 
        'lon' => '-63.632813', 
        'lat' => '-32.287133'
      ],
      2 => [
        'type' => 'point', 
        'lon' => '-65.566406', 
        'lat' => '-37.195331'
      ],
    ];
    
    $map_info = \Drupal::service('leaflet.service')->leafletMapGetInfo()['my_map'];
    $build['map'] = \Drupal::service('leaflet.service')->leafletRenderMap($map_info, $map_features, '450px');
    
Production build 0.71.5 2024