ayastreb / jekyll-maps

:earth_americas: Embed maps with filterable locations in Jekyll

Home Page:https://ayastreb.me/jekyll-maps/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jekyll 4.x - Map tag included in layout issue

Gerfaut opened this issue · comments

Hello,
I noticed an strange issue occurring only on Jekyll 4+ and if the map tag is included directly in a layout file: the map is showing the location of the current post + the posts before.
Map of first post will be correct, map of second post will display map from first post and second post, etc.
image
image

The issue is not occurring when inserting the tag directly in the post content or using jekyll 3.x. Is this something about the new jekyll cache feature?

I created a repository to reproduce the issue easily: https://github.com/Gerfaut/jekyll-maps-issue
Is there anything we can do on the jekyll-maps gem to fix that or is this meant to work like that?

Thanks a lot for your help,
Gerfaut

I believe this is because class GoogleMapTag < Liquid::Tag is always created on every tag rendering.
Hence, LocationFinder instance is kept between pages to render, and @documents is not cleaned.

To fix it, you have to ensure LocationFinder is created from scratch on every GoogleMapTag.render invocation.

The change #50 should fix the issue.