• Resolved timjh

    (@timjh)


    Simon – not reporting a bug with your brilliant plugin, but I hope you find this to be an interesting use case. I am building a map with many markers that name fields around our village. (Currently showing only about 40 of the 300 names I have). I would like to add an index of names below the map such that clicking on a name scrolls the page back to the map (or pops it up) and zooms in on the relevant marker with its label displayed. Can you offer any tips on how this might be implemented?

    • This topic was modified 3 years, 1 month ago by timjh.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author skirridsystems

    (@skirridsystems)

    The nearest I can find is this one on Stack Exchange
    https://gis.stackexchange.com/questions/147052/leaflet-js-map-pan-too-and-zoom-in-on-point

    It can be made to fit your specific use case, but I’m not sure how it could be generalised. Possibly an option to follow the map with a

      list of points, which you can then format to your liking using CSS? Would that work for you?
    Thread Starter timjh

    (@timjh)

    Thanks very much for finding that reference, and yes, I think your suggested approach would work for me. The order of the list would be important – presumably it would be simple to preserve the order in which the markers are defined in the markerfile or markers list.

    Thinking about a bit more generalisation: Obviously each list item should default to showing the marker label, but it might be nice to be able to modify it for display – perhaps via a hook? (Probably better than adding a “list-item-label” field to the already complex marker definition.) It might also be nice to have a hook for manipulating the list, eg to drop items or re-order, or insert additional HTML for grouping purposes.

    Someone may want to embed a marker link in text on the same page: they could do this by enabling the list option, copying and pasting the link from the list and then disabling the list, or suppressing it in the CSS. I would actually find it useful to embed a marker link in text on a different page; I suppose that would need some URL query parameters; perhaps a step too far :-).

    The code in the reference you found looks fairly straightforward, although I’m not sure how to make it work alongside the plugin. Have I piqued your interest enough for you to add it to your to-do list? I’d willingly run tests!

    • This reply was modified 3 years, 1 month ago by timjh.
    • This reply was modified 3 years, 1 month ago by timjh.
    • This reply was modified 3 years, 1 month ago by timjh.
    Plugin Author skirridsystems

    (@skirridsystems)

    I’ll add it to the to-do list to look at. No guarantees when, but in principle it seems doable.

    Thread Starter timjh

    (@timjh)

    Great! Thanks.

    Plugin Author skirridsystems

    (@skirridsystems)

    Sorry, didn’t manage to get this into 1.3. I’ve done a fairly major restructure of the JS generator and didn’t want to change too much in one go! But I haven’t forgotten.

    Thread Starter timjh

    (@timjh)

    Simon – thanks for updating me. Coincidentally, I had just spent a bit of time this week implementing a marker index. Today’s task was to make it work with v1.3 :-(. You can see it in action on the page referenced in my original post.

    I had to hack os-datahub-maps.js to capture handles to (a) the map and (b) an array of marker layers (I wonder if there is a better way to get at these?).

    I used a do_shortcode_tag hook on [osmap] to append the name index below the map. In the index, each name is a link to the map (to make it scroll into view) and holds a data attribute for the array index of the relevant marker layer.

    My JS script, responding to a click on a name, takes just a few lines to retrieve the marker index, fly to the marker and pop it open.

    I don’t like the long list of names in a single column, but a bit of CSS will fix that shortly.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Constructing a marker index’ is closed to new replies.