• Apparently it is not possible to have text or html content within leaflet-geojson like it is possible with leaflet-marker. I’m thinking about this:

    [leaflet-geojson]
    blabla
    <a href="/fred.html">
    [/leaflet-geojson]

    Allowing this would be much more convenient compared to the attribute “popup_text” as the latter won’t allow for quotes for example.

    would this be hard to implement?

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

    (@bozdoz)

    Fixed in newest version (2.8.0, coming shortly)

    Thread Starter joze

    (@joze)

    wow, thanks for the rapid implementation!

    But: something seems to be broken now. I just updated to 2.8.0 and no markers are shown at all now. Also the “shortcode helper” page seems to be broken and doesn’t show markers any more.

    js errors shown:

    Uncaught TypeError: WPLeafletMapPlugin.getCurrentMarkerGroup is not a function
        at admin.php?page=leaflet-get-shortcode:274
        at init (construct-leaflet-map.js?ver=1.0:9)

    or

    Uncaught TypeError: WPLeafletMapPlugin.getCurrentMarkerGroup is not a function
        at (index):224
        at init (construct-leaflet-map.js?ver=1.0:9)
    Thread Starter joze

    (@joze)

    hmm. markers are there again, though I didn’t change anything. Maybe a cache problem. Sorry for bandwidth.

    There’s another problem though.

    [leaflet-geojson src="/tmp.geojson"]fred[/leaflet-geojson]

    translates into

    popup_text = 'fred'

    which is ok.

    BUT:

    [leaflet-geojson src="/tmp.geojson"]<div>fred</div>[/leaflet-geojson]

    translates into

    popup_text = ‘
    <div>fred</div>
    <p>’

    Note that some newlines appeared in the text which is NOT ok and generates an error "Uncaught SyntaxError: Invalid or unexpected token"

    If I use any html which is more complex than simple text, it is translated somehow to multiline text which generates errors.

    Any ideas?

    • This reply was modified 7 years, 3 months ago by joze.
    • This reply was modified 7 years, 3 months ago by joze.
    • This reply was modified 7 years, 3 months ago by joze.
    • This reply was modified 7 years, 3 months ago by joze.
    Plugin Author bozdoz

    (@bozdoz)

    I tried adding a div like your example and found that WordPress was (understandably) adding paragraph tags, which broke the JavaScript.

    So I made some adjustments and believe I’ve made it able to handle custom HTML. Give 2.8.1 a try and let me know how that works.

    Thread Starter joze

    (@joze)

    @bozdoz

    thanks again. Here’s what I get:

    1. spreading marker or geojson content across several lines doesn’t work any more. This doesn’t work (it worked at least for markers but not for geojson before):

    [leaflet-marker]
    blabla
    <a href="/fred.html">
    [/leaflet-marker]

    2. what works for both markers and geojson is if I have everything in one line like this:

    [leaflet-marker]blabla<a href="/fred.html">[/leaflet-marker]

    3. having div’s does not only introduce paragraphs (I don’t understand why, but anyway) but additionally it introduces newlines, so if the content between the shortcodes has div’s like this:

    [leaflet-marker]<div>blabla<a href="/fred.html"><div>[/leaflet-marker]

    the resulting js has newlines within the string, which gives errors (note the line breaks):

    marker.bindPopup(WPLeafletMapPlugin.unescape('</p>
    <div>blabla<a href=&quot;/fred.html&quot;></p>
    <div>'));

    To summarize:

    I changed my code to not use div’s any more and therefore it works ??

    • This reply was modified 7 years, 3 months ago by joze.
    • This reply was modified 7 years, 3 months ago by joze.
    Plugin Author bozdoz

    (@bozdoz)

    Wordpress adds paragraph tags to any line break from the editor (and this includes shortcodes). It makes sense for pure text.

    So I think I have a solution to multi-line text. I’ll strip new lines and replace them with <br> tags so that the JavaScript doesn’t break.

    Will be the next version; maybe tomorrow.

    Also, I’m surprised the div’s didn’t work. I specifically tested div’s and they worked fine.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘text or html content within leaflet-geojson shortcodes’ is closed to new replies.