Problem/Motivation

Uncaught TypeError: can't access property "indexOf", i is undefined
addTo Control.js:76
addControl Control.js:137
setPosition Control.js:52
initialise leaflet.drupal.js:278
Leaflet leaflet.drupal.js:225
loadMap leaflet.drupal.js:23
attach leaflet.drupal.js:193
attach leaflet.drupal.js:15
each jQuery
attach leaflet.drupal.js:10
attachBehaviors drupal.js:166
attachBehaviors drupal.js:162
htmx-behaviors.js:16
ae htmx.min.js:1
htmx-assets.js:148
promise callback* htmx-assets.js:139
ae htmx.min.js:1
n htmx.min.js:1
ie htmx.min.js:1
n htmx.min.js:1
e htmx.min.js:1
ze htmx.min.js:1
insert big_pipe.commands.js:79
insert big_pipe.commands.js:74
commandExecutionQueue big_pipe.commands.js:31
promise callback*Drupal.bigPipe.commandExecutionQueue/< big_pipe.commands.js:24
commandExecutionQueue big_pipe.commands.js:21
processReplacement big_pipe.js:69
checkMutationAndProcess big_pipe.js:94
processMutations big_pipe.js:118
processMutations big_pipe.js:117
MutationCallback* big_pipe.js:134
big_pipe.js:166
Control.js:76:33

Steps to reproduce

console error due to missing Map files.

Proposed resolution

change .library to use /libraries/leaflet... base

Remaining tasks

User interface changes

none

API changes

none

Data model changes

location of basic js plugin installed in /libraries/leaflet with the correct map files.

Issue fork leaflet-3588827

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

skaught created an issue. See original summary.

skaught’s picture

Issue summary: View changes

skaught’s picture

Status: Active » Needs review
itamair’s picture

Category: Bug report » Support request
Status: Needs review » Closed (works as designed)

Not clear at all the use case that is causing what you repot, and how to reproduce (you don't explain and don't even mention ... ).
The Leaflet Js library is correctly being loaded in the Drupal Leaflet module 10.4.x-dev (and previous releses).

More over the created MR !70 is pointing/looking to a Leaflet Js library that is assumed to be (magically?) present in the /library folder,
and thus finding it and breaking every (not rendering any) Leaflet map ...

It looks the issue being reported here is sourced by a very personal (and not typical) Drupal Leaflet module setup, totally not reproducible.
And the provide solution is totally arbitrary and not working ...

Indeed everything works as designed with the Leaflet Js loading in the Drupal Leaflet module ...

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

skaught’s picture

my direct use-case is using code to draw a map into a block output:


    // if no coord.  then supply a default image.
    $features[] = [
      'type' => 'point',
      'lat' => $coordinates['lat'],
      'lon' => $coordinates['lng'],
    ];
    $map_service = \Drupal::service('leaflet.service');
    $map_info = $map_service->leafletMapGetInfo('openstreetmap');
    $map_info['settings']['map_position_force'] = 0;
    $map_info['settings']['zoomControlPosition'] = false;
    $map_info['settings']['zoomControl'] = false;
    $map_info['settings']['zoom'] = 8;
    $map_info['settings']['attributionControl'] = false;
  //  $map_info['settings']['scrollWheelZoom'] = 'false';
    $map_info['settings']['center'] = ['lat' => $coordinates['lat'], 'lon' => $coordinates['lng']];
  //  $map_info['settings']['fullscreen_control'] = 0;
    $map = $map_service->leafletRenderMap($map_info, $features, '290px');
itamair’s picture

Then of course you (still) need to load the leaflet-drupal library
https://git.drupalcode.org/project/leaflet/-/blob/10.4.x/leaflet.librari...
in your theme or that specific page anyway ...
ref: https://www.drupal.org/docs/develop/creating-modules/adding-assets-css-j...