• Resolved hydrones

    (@hydrones)


    Hello there,

    I already read quite similar topic about markers which are not showing but did not find my solution..Basically I just wanted to add map of an area based on leaflet, and add then a marker on this map. Something close to that:
    [leaflet-map lat=44.841680 lng=-0.566745 zoomcontrol=”1″ zoom=7]
    [leaflet-marker]
    As a result, I can get a map but no markers. Instead my browser console highlights some errors:
    previous_map = WPLeafletMapPlugin.maps[ map_count – 1 ],
    is_image = previous_map.is_image_map,
    image_len = WPLeafletMapPlugin.images.length,
    previous_image = WPLeafletMapPlugin.images[ image_len – 1 ],
    previous_image_onload;</p><p> if ( is_image &&
    ..On the last line, the error message starts from </p><p>
    If I put out the leaflet-marker I have no such error anymore.
    Precision: I’ve tried to remove and reinstall, and also tried to remove the default attribution in the plugin default values, but nothing happened.

    Thanks a lot! My configuration: Chrome V 55.0.2883.95, Mac OS 10.11.6

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author bozdoz

    (@bozdoz)

    Hi! Sorry for the late reply. I don’t see an explicit error in your post. Perhaps you could post the full console, or send me a link?

    This does appear to be a similar topic to some previous topics, but most were not reproducible and some were WordPress theme/plugin issues (like CSS).

    Plugin Author bozdoz

    (@bozdoz)

    This might be fixed with the updated plugin. Could you update and see if the problem persists? Thanks!

    Thread Starter hydrones

    (@hydrones)

    Hi bozdoz,
    It’s my turn now to apologize, I just saw your answer.
    Basically I wanted to had a leaflet marker to my map but it did not work.
    When I had [leaflet-marker lat=44.67 lng=-63.61] after [leaflet-map lat=44.652535694663875 lng=-0.34855842590332037 zoom=14]
    I get SyntaxError: Unexpected token ‘<‘.

    Hereafter what is in the console, the message error focus the line with the “*”:
    <div id=”leaflet-wordpress-map-1″ class=”leaflet-wordpress-map” style=”height:350px; width:100%;”></div><p><script>
    WPLeafletMapPlugin.add(function () {
    var baseUrl = ‘https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}.png’,
    base = (!baseUrl && window.MQ) ? MQ.mapLayer() : L.tileLayer(baseUrl, {
    subdomains: ‘abcd’
    }),
    options = L.Util.extend({}, {
    maxZoom: 20,
    minZoom: 0,
    layers: [base],
    zoomControl: 1,
    scrollWheelZoom: 0,
    attributionControl: false
    }, {}),
    map = L.map(‘leaflet-wordpress-map-1’, options).setView([44.841680, -0.566745], 7);
    WPLeafletMapPlugin.maps.push(map);
    }); // end add
    </script><br />
    <script>
    WPLeafletMapPlugin.add(function () {
    var map_count = 1,
    draggable = false,
    marker = L.marker([44.67, -63.61], { draggable : draggable }),
    previous_map = WPLeafletMapPlugin.maps[ map_count – 1 ],
    is_image = previous_map.is_image_map,
    image_len = WPLeafletMapPlugin.images.length,
    previous_image = WPLeafletMapPlugin.images[ image_len – 1 ],
    *previous_image_onload;</p><p>* if (draggable) {
    marker.on(‘dragend’, function () {
    var latlng = this.getLatLng(),
    lat = latlng.lat,
    lng = latlng.lng;
    if (is_image) {
    console.log(‘leaflet-marker y=’ + lat + ‘ x=’ + lng);
    } else {
    console.log(‘leaflet-marker lat=’ + lat + ‘ lng=’ + lng);
    }
    });
    }</p><p> marker.addTo( previous_map );</p><p> WPLeafletMapPlugin.markers.push( marker );
    }); // end add function
    </script></section>
    </div>

    I am updating the plugin and keep you informed immediately, thanks!

    Thread Starter hydrones

    (@hydrones)

    Well, I still get the same SyntaxError: Unexpected token ‘<‘ still at the same line as before, and then my marker do not appear on the map. Any idea?

    Thread Starter hydrones

    (@hydrones)

    Another information: it seems that there is a conflict between Leaflet plugin and wp-d3 js plugin. I made a test: when wp-d3 js is desactivated, there is no problem to display the marker on the map with Leaflet.
    Actually I use both of them on my web page: Leaflet to show a map with the location of measurements, and wp-d3 js to plot the measurements.

    Plugin Author bozdoz

    (@bozdoz)

    Looks like it’s adding paragraphs within the leaflet shortcodes.

    Possibly you can fix it with instruction here:

    https://customcreative.co.uk/resolving-wpautop-and-shortcodes/

    Adding the following code to your functions.php will make sure that it runs after everything else, keeping the usability but stopping the random insertions:

    remove_filter( ‘the_content’, ‘wpautop’ );
    add_filter( ‘the_content’, ‘wpautop’ , 99);

    It’s possible that the wp-d3 theme is adding wpautop, and perhaps newer themes are not using it; and that could be why I cannot reproduce this error.

    Plugin Author bozdoz

    (@bozdoz)

    Also I may have fixed my plugin by removing the newlines in the JavaScript (so that other plugins/themes won’t even think to put p tags in it). New version is 2.7.2! Tested with WP-d3

    Thread Starter hydrones

    (@hydrones)

    Dear bozdoz,

    Thanks to your 2.7.2 release I have no problems anymore! Thanks a lot for your plugin, and thank you so much for your help today.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Markers are not visible’ is closed to new replies.