0

Normally people want to add multiple markers to a single map. In my case I'm attempting almost the opposite - create two maps from the same content type and using Leaflet assign each a unique marker to each. Try as I might I can't figure out how to do this. Instead, what happens is that both markers are displayed on either map (rather than one per map).

My current setup it like so -

Content type

  • Has a geofield set to output Lat/ Long coordinates

Page

  • Two pages based on the above content type (let's call them Page Map A and Page Map B) each have a unique set of coordinates.

View

  • Individual View block for Page Map A and also for Page Map B. These are set to output the geofield data

(I originally had one View block and I was hoping that splitting them in two would solve the issue. It didn't.)

Block

  • In blocks the View for Map A and the View for Map B is set to display only on their respective pages

Both of the Views are ordered by sort date (which might be the source of the problem) and only show 1 item. However, if only one item is set to show then it's always the marker for Page Map B that's displayed. Furthermore, if I increase the display to show 2 or more items then the popup text for both markers will only appear on Page Map B, and there are no popups for Page Map A.

0

I would use a contextual filter (Advanced settings column) based on the content NID (node identifier). You will get a settings window where you choose "Provide default value" and Type : Content ID from URL (the nid is always available from URL even if you use an alias). Then, the Leaflet map will be filtered using this NID and you will get only one marker (display all results and remove your sort date) created with coordinates entered for this specific content (page). Finally, you will need only one block with this contextual filter, since it will be automatically modified according to page URL.

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.