Home Forums Gutenberg Google Maps block with data from other blocks on same page


Google Maps block with data from other blocks on same page

  • I would like to move Google Maps from being coded into my template to being a block. This is actually pretty easy with ACF. Custom Block → Google Maps-JS → done.

    On the same page I use another block (“business location”), which includes Google Maps data (i.e. coordinates). In the pre-all-in-Gutenberg world I used to have these blocks parsed, their geo-data extracted and displayed on the Google Map.

    I would like the same thing to happen, but inside Gutenberg and – even better – in real time: I add a new business location-block and I see a new marker on the Google Maps-block.

    TBH, I do not even know where to start. Anyone interested in helping me out here? Pointers are enough, code samples make you the superhero you know you are!

  • This is my solution for now: In the business location-block I add some data-attributes to the html output. In the maps-block I basically do nothing, except parsing each (in my case: li) li.location for these data-values and add it as markers to the map. This works in the frontend only, but it works.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.