Leaflet Map settings for DivIcon size and anchor are ignored

Created on 4 March 2025, 29 days ago

Problem/Motivation

After upgrading to Leaflet 10.2.42 it was observed that Leaflet marker DivIcons produced by the Leaflet Map formatter (used to display a geofield field) were always 12px wide and tall, despite our settings; the anchor is also incorrect. This appears to have been introduced in 10.2.39 by the commit for #3377484.

Map with bug:

Same map after applying a patch to reverse #3377484:

Note that we use the Field (html DivIcon) setting in the format config with an SVG USE element to display the icon; switching to the Icon Image Url/Path does not work because that will make an IMG element.

Steps to reproduce

View a geofield which uses the Leaflet Map format, with "Field" Map Icon using custom icon size and anchor settings
Observe that the marker is 12px x 12px and offset -6px left and up.

Proposed resolution

I am not encountering the fatal error reported in #3377484 and would say that issue should be reversed and reopened.

I assume that issue occurs when trying to instantiate a point for which no Lat/Lng is provided. I may be mistaken but I think the icon size and anchor (and popup anchor) are only used to offset from the calculated lat/lng pixel, and so the issue would be occurring elsewhere in the marker placement chain.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

10.2

Component

Code

Created by

🇺🇸United States wsantell

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

Comments & Activities

  • Issue created by @wsantell
  • 🇮🇹Italy itamair

    Hey @wsantell ... thanks for reporting this, and sorry for this regression.

    Please, let me properly understand the specific context.

    You say ...

    Steps to reproduce
    View a geofield which uses the Leaflet Map format, with "Field" Map Icon using custom icon size and anchor settings
    Observe that the marker is 12px x 12px and offset -6px left and up.

    BUT, is this happening only in case of DivIcons ... right?
    Can you confirm that we should test and reproduce this specifically with DIVIcon?

    Because that commit only changed the Drupal.Leaflet.prototype.create_divicon function ...

    • itamair committed 01a344c5 on 10.2.x
      Restored and fixed correct DivIcon definition with its properties
      (Issue...
  • 🇮🇹Italy itamair

    Ok ... got all this.
    New leaflet 10.2.43 release (just deployed) is fixing this,
    and is also keeping fixed the related https://www.drupal.org/project/leaflet/issues/3377484 🐛 Uncaught Error: Invalid LatLng object: (NaN, NaN) Active one.

    Closing this as fixed.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024