- Issue created by @cianevans
- Status changed to Closed: works as designed
over 1 year ago 1:47pm 3 August 2023 - 🇮🇹Italy itamair
Thanks @cianevans for reporting this ...
Actually the $feature['popup'] definition changed (from simple HTML markup to array ... ) from 2.x to 10x Leaflet versions,
but backward compatibility and seamless upgrade path was implemented for that.I checked again that it could still work upgrading from 2.x to the latest 10.0.19 Leaflet version,
and I successfully QAed and Tested it, all successfully with different Leaflet Popup definitions (specific field, or Rendered Entity, and also # Rendered Via fields ... ): my Leaflet Popups renderings are not broken (lost) upgrading from v2.2.5 to v10.0.19,
so I couldn't reproduce this issue in your use case.Also I should report that new 10.x Leaflet version already registers more than 7 k adoptions, and this Bug issue that you report is not duplicating anything existing (and still open) one, that basically means nobody reported this same issue/bug of you, and latest 10.0.x didn't bring any further changes in the $feature['popup'] definition ...
All that simple brings me the outcome that we don't have any clear evidence of any bug here, so I am going to close this as "Closed (works as designed)". Please reopen this ONLY if you can clearly give evidence / prove where the Bug occurs in the code.
At the same time I cannot question / doubt that you (unfortunately ... probably for some un-expected happening or in some configurations workflow) lost your Leaflet Popup rendering.
The proper and best way to fix them is just to re-set / re-configure them in the Leaflet Formatter and Leaflet View Style settings ... and you will be easily all set, back on track.
I have the same problem in my project.
My module leaflet is in the version 2.0.5 and when i upgrade my module to 10.0.19, my popup and marker disappear.
And in my console i have this error:Uncaught TypeError: Cannot read properties of undefined (reading 'indexOf') at e.addTo (Control.js:76:11) at e.addControl (Control.js:137:11) at e.setPosition (Control.js:52:8) at Drupal.Leaflet.initialise (leaflet.drupal.js?v=9.5.9:251:27) at new Drupal.Leaflet (leaflet.drupal.js?v=9.5.9:202:10) at loadMap (leaflet.drupal.js?v=9.5.9:23:45) at HTMLDivElement.<anonymous> (leaflet.drupal.js?v=9.5.9:168:13) at Function.each (jquery.min.js?v=3.6.3:2:3003) at E.fn.init.each (jquery.min.js?v=3.6.3:2:1481) at Object.<anonymous> (leaflet.drupal.js?v=9.5.9:14:26)
- 🇬🇧United Kingdom cianevans
Hi @itamair
Thank you for testing. Regarding your advice:
The proper and best way to fix them is just to re-set / re-configure them in the Leaflet Formatter and Leaflet View Style settings ... and you will be easily all set, back on track.
Are you able to advise further on this? I'm not sure how exactly to re-set them as this is an inherited site so I did not set up the views originally.
I have tried in the view clicking 'Settings' near 'Format: Leaflet Map' and comparing to the live site and everything seems identical. I have tried for example switching the popup source from 'Content datasource: ID (indexed field)' to 'Content datasource: Title (indexed field)' to try and 'reset' and show the title instead of description but unforunately popup content is not displayed.I have inspected the popup in the web console to confirm if its a styling issue, but the html of the popup content is not rendered to the page, so styling is not the issue at least.
- 🇳🇴Norway vegardjo
Hi, I also have this issue after upgrading to d10 and then Leaflet 10.2.12 on a project. The DOM for the
.leaflet-popup-content
is simply empty.There are no console errors or php logs. The issue is both in views, and when the field is rendered through the field formatter on a node. Tried with php 8.1 and 8.2.
I have tried making a complete new view with one node, and configured the view display again. Whatever I put as Popup Source below Leaftet Popup har the same result of nothing rendered. Also, both "Leaflet Tooltip" and "Simple Tooltip" works as it should.
Did anyone figure this out?
- 🇳🇴Norway vegardjo
I figured it out, we had an implementation of
hook_leaflet_views_feature_alter()
that altered$feature['popup']
, and that after the update needs to alter$feature['popup']['value']
instead. - 🇬🇧United Kingdom cianevans
Code update in #6 worked for me too. Thank you vegardjo!
- 🇺🇸United States selwynpolit
Thanks! #6 worked for me too:
$build = []; $points = [ ['lat' => 37.7749, 'lon' => -122.4194, 'city' => 'San Francisco', 'job' => 'Software Engineer'], ['lat' => 34.0522, 'lon' => -118.2437, 'city' => 'Los Angeles', 'job' => 'Data Analyst'], ['lat' => 36.746841, 'lon' => -119.772591, 'city' => 'Fresno', 'job' => 'Web Developer'], ['lat' => 30.2672, 'lon' => -97.7431, 'city' => 'Austin', 'job' => 'Software Engineer'], ]; // Convert points to features. $features = []; foreach ($points as $point) { $popupContent = $point['city'] . '<br>Lat: ' . $point['lat'] . '<br>Lon: ' . $point['lon'] . '<br>Job: ' . $point['job']; $features[] = [ 'type' => 'point', 'lat' => $point['lat'], 'lon' => $point['lon'], 'popup' => [ 'value' => $popupContent, ], ]; } // Create a map with the features. $map = leaflet_map_get_info('OSM Mapnik'); $build['map'] = $this->leafletService->leafletRenderMap($map, $features, '500px'); return $build; }
- 🇺🇸United States jcorrao
As someone making the upgrade from Leaflet 2.1 to the latest 10.2, #6 also helped me out with figuring out why all the popups were mysteriously empty!
Is there any upgrade documentation that details the underlying changes like these in the underlying PHP or JS code?