TypeError: Cannot read properties of undefined (reading 'lMap')

Created on 23 July 2024, 8 months ago
Updated 24 July 2024, 8 months ago

Problem/Motivation

The system provides an issue when displaying a View with nodes (with Geofield values) on a Leaflet map.

Steps to reproduce

  1. Install the module with composer and activate it. Geofield and Leaflet were previously installed.
  2. Create a view with node content with Geofield data. Display based on Leaflet.
  3. Set the filter with Polygon Draw according to the documentation. The issue comes out from the console log even in the preview.

Displayed error:

TypeError: Cannot read properties of undefined (reading 'lMap') at views_polygon_search_freedraw.js?v=1:174:38

Coming from const map = $('.view-content > div[id*=leaflet-map]', $view);, it seems that const mapData = map.data("leaflet"); returns an undefined value.

Proposed solution

Change the line const map = $('.view-content > div[id*=leaflet-map]', $view);
Into const map = $('div[id*=leaflet-map]');

It seems to be working but should be reviewed by the community.

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

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

Comments & Activities

Production build 0.71.5 2024