Skip to main content
12 events
when toggle format what by license comment
Jun 6, 2020 at 10:42 vote accept Isabella
Jun 6, 2020 at 9:41 comment added Isabella But changing input was necessary. Thank you.
Jun 6, 2020 at 9:34 comment added Isabella Somehow I couldn't get your suggestions to work. Using console.log(e.latlng); e.layer.openPopup(); now and it opens my popups without me having to define something new.
Jun 5, 2020 at 9:01 comment added TomazicM These methods work only if popup is already defined for the layer. If not, you have to use .bindPopup() method.
Jun 5, 2020 at 8:22 comment added Isabella Tried ` layer.getPopup().setContent('test') layer.openPopup();` and layer.setPopupContent('test') layer.openPopup();. In both cases I get Cannot read property 'getPopup' of undefined and Cannot read property 'setPopupContent' of undefined. When I use e.layer.getPopup().setContent('test'); e.layer.openPopup(); it's opening the Popup, but feature.properties.name in setContent() (and the other case with setPopupContent()) isn't working.
Jun 5, 2020 at 8:05 comment added TomazicM Method .setContent() is for popup object, .setPopupContent() is for layer object. In your case you are setting popup content of a layer. If you want to use .setContent, then it should be layer.getPopup().setContent(…)
Jun 5, 2020 at 8:00 comment added Isabella No, setContent() is right. leafletjs.com/reference-1.6.0.html#popup-setcontent (And even with setPopupContent, I get the same error.)
Jun 5, 2020 at 6:12 comment added TomazicM Ups, my mistake, it should be layer.setPopupContent(…). Answer edited and corrected.
Jun 5, 2020 at 6:11 history edited TomazicM CC BY-SA 4.0
Corrected error in setting popup content.
Jun 5, 2020 at 6:05 history edited TomazicM CC BY-SA 4.0
Corrected error in setting popup content.
Jun 4, 2020 at 20:07 comment added Isabella Oh, thank you. I tried layer.setContent(feature.properties.name); layer.openPopup(); but it can't read the setContent(). Cannot read property 'setContent' of undefined. I tried e.layer.bindPopup('test').openPopup() console.log(e.latlng) and at least it's opening a popup. But as soon as I wanna use the setContent() it's not working anymore.
Jun 4, 2020 at 17:45 history answered TomazicM CC BY-SA 4.0