Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Leaflet trying to load "infinite amount of tiles" #9233

Merged
merged 1 commit into from May 5, 2022

Conversation

ahukkanen
Copy link
Contributor

@ahukkanen ahukkanen commented May 5, 2022

🎩 What? Why?

While testing #9156 I noticed that when we display the static map through Leaflet, there is the following error displayed in the developer console:

Uncaught Error: Attempted to load an infinite number of tiles
    at NewClass._update (leaflet-src.js:11068:1)
    at NewClass._setView (leaflet-src.js:10977:1)
    at NewClass._resetView (leaflet-src.js:10935:1)
    at NewClass.onAdd (leaflet-src.js:10572:1)
    at NewClass.onAdd (leaflet-tilelayer-here.js:115:1)
    at NewClass._layerAdd (leaflet-src.js:6487:1)
    at NewClass.fire (leaflet-src.js:593:1)
    at NewClass._resetView (leaflet-src.js:4117:1)
    at NewClass.setView (leaflet-src.js:3164:1)
    at NewClass.panTo (leaflet-src.js:3266:1)

After further investigation, the reason seems to be when we try to setView before defining a zoom value as explained here:
Leaflet/Leaflet#6416 (comment)

This usually happens when you setView the first time without defining zoom or defining zoom incorrectly

So, moving the setZoom call before the panTo call seems to fix this issue.

📌 Related Issues

Testing

Configure the static maps to be displayed through leaflet with the following configuration at config/initializers/decidim.rb:

  # Leave out the "static" config in which case Leaflet will be used as a fallback
  config.maps = {
     provider: :here,
     api_key: Rails.application.secrets.maps[:dynamic_api_key]
  }

After this:

  • Make sure you have MAPS_API_KEY defined in your environment configs
  • Enable geocoding for the proposals component
  • Create one proposal with address and latitude/longitude assigned to it
  • Go to the proposal preview or show view and see there are no errors in the developer console

📋 Checklist

  • CONSIDER adding a unit test if your PR resolves an issue.
  • ✔️ DO check open PR's to avoid duplicates.
  • ✔️ DO keep pull requests small so they can be easily reviewed.
  • ✔️ DO build locally before pushing.
  • ✔️ DO make sure tests pass.
  • ✔️ DO make sure any new changes are documented in docs/.
  • ✔️ DO add and modify seeds if necessary.
  • ✔️ DO add CHANGELOG upgrade notes if required.
  • ✔️ DO add to GraphQL API if there are new public fields.
  • ✔️ DO add link to MetaDecidim if it's a new feature.
  • AVOID breaking the continuous integration build.
  • AVOID making significant changes to the overall architecture.

@ahukkanen ahukkanen added module: core type: fix PRs that implement a fix for a bug labels May 5, 2022
Copy link
Contributor

@microstudi microstudi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: core type: fix PRs that implement a fix for a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants