• Resolved schneidan

    (@schneidan)


    Trying to get a map that displays multiple shapefiles to also make a popup for each one with a link in it. I’ve also tried hacking the plugin in a bit to make the shapefile link to another page when a given shape is clicked on, without success.

    Working with this chunk to add shapes to the map:

    $marker_text = '<h3>' . get_the_title() . '</h3><p><a href=\"' . get_the_permalink() . '\">Check out the neighborhood</a></p>';
    echo do_shortcode('[leaflet-geojson src="' . $map_shape_file_url . '" fitbounds=true popup_property="' . $marker_text . '"]');

    As far as I can tell from the output it’s as correct as I can get it, and the shapefiles appear on the map, but none does anything when clicked. Wondering if you have any insight…

    Thanks!

    • This topic was modified 7 years, 7 months ago by schneidan.
    • This topic was modified 7 years, 7 months ago by schneidan.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author bozdoz

    (@bozdoz)

    Will be fixed in new version. See most recent forum post.

    Thread Starter schneidan

    (@schneidan)

    Awesome! Just tested v. 2.8.1 and it’s working pretty well! I’d still love, as an idea, a way to add a URL to direct the user to when a GeoJSON shape is clicked. But that might also require an onHover label of some kind. So many ideas!

    Thanks!

    Plugin Author bozdoz

    (@bozdoz)

    Yeah, I see what you’re saying. Would require JavaScript (more than just adding text via JavaScript), unless I add an attribute that is something like on_click_open_link="http...". I just don’t know how useful that is generally. It might be better if I do an action, and developers can extend it by adding to that action. Does that make sense?

    Thread Starter schneidan

    (@schneidan)

    Yeah, I was thinking it would be a JS action added as through the onEachFeature bit like on('click', function() { window.location.href = '{$on_click_open_link}'; });

    that would solve things for me personally, but then would probably, like I said, need a popup label of some kind.

    What would the action version look like? Just a way to add code to the onEachFeature loop?

    Thanks!

    Plugin Author bozdoz

    (@bozdoz)

    Yeah the action would be in the onEachFeature function

    Thread Starter schneidan

    (@schneidan)

    I’d worry that the freedom to insert script there might represent a security vulnerability? But security stuff isn’t my forte. The ability to insert a function there somehow would be pretty cool, for sure.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘New problem with links or popups on GeoJSON’ is closed to new replies.