3

I'm trying to use the Wikipedia layer in english: http://mappingforyou.eu/javascript/Leaflet.Wikipedia.js

but I'm not successful on using the leaflet infotips "BindPopup". The code could be working with a sidebar, but I prefer infotips. Can you correct the line for me please?

enter image description here

function onMoveEnd(evt) {

  var template = '<h2>{label}</h2><p><img src="{thumbnail}">{abstract}</p><p><a href="{link}">Read on Wikipedia</a></p>';

  L.wikipedia({
    query: {
      fields: \['label', 'lat', 'lng', 'abstract', 'link', 'thumbnail'\],
      bounds: map.getBounds()
    },
    marker: {
      icon: L.icon({ // Icons from http://www.icondrawer.com/social-icons.php
        iconUrl: 'http://mappingforyou.eu/icons/wikipedia_16.png',
        iconRetinaUrl: 'http://mappingforyou.eu/icons/wikipedia_32.png',
        iconSize: \[16, 16\]
      })
    }
  }).addTo(map).on('click', function (evt) {
    evt.layer.bindPopup((template), customOptions);

    // previous code referring to sidebar

    //  sidebar.setContent(L.Util.template(template, evt.layer.data)).show();

  });
}

map.on('moveend', onMoveEnd);
3

the

      evt.layer.bindPopup((template), customOptions);

was replaced with

      evt.layer.bindPopup(L.Util.template(template, evt.layer.data), customOptions);

and successfully managed to show the data.

enter image description here

1
  • Bonus question: how do you add geolocation to a Wikipedia article? ;)
    – Vincent Dc
    Jan 4 at 0:15

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.