-
Notifications
You must be signed in to change notification settings - Fork 10
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
Setting the map ID dynamically doesn't work #23
Comments
Interesting. Are you creating multiple maps in a loop? Would you mind sharing the Twig loop which is generating the map(s)? |
Realistically we're not, but it's theoretically possible so I need to make sure it works. For context, we usually build 90% of our pages with a Matrix field. So in that matrix field there's a map block. Usually when I do anything with JS or something that needs a unique identifier for javascript (like a carousel or map), I use the _includes/contentMatrix.twig:
_includes/content/map.twig:
That |
I'm having trouble reproducing the bug that you saw. Let's take this to DM via Craft Discord, and we can report back here when we have more information. |
Thanks for your time on this Lindsey! For future reference, using a dynamic ID works fine; this error was caused because I was already using |
Awesome, glad it's all sorted out! I'll see if I can refine the error message to prevent this issue from popping up in the future. |
Thank you Lindsey! |
If you want to do anything with the map in JS or Twig, you have to know it's ID. In Smart Maps, this was reliably
smartmap-mapcanvas-1
. In Google Maps, it's random every time the page loads.If I do this, it works fine:
But if I try to use the block's ID, so that it's still unique if the map matrix block is added twice,
Then I get a JS console error saying the block is missing DNA:
The text was updated successfully, but these errors were encountered: