Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Popups not populated for non-spiderfied markers #44

Open
MelanieEmmajade opened this issue Oct 15, 2018 · 1 comment
Open

Popups not populated for non-spiderfied markers #44

MelanieEmmajade opened this issue Oct 15, 2018 · 1 comment

Comments

@MelanieEmmajade
Copy link

Marker popups show empty for any markers that are not spiderfied. Appears to be equivalent to this issue Leaflet/Leaflet.markercluster#24. Markers that are spiderfied work fine. I am using the oms.min.js file with the timestamp /* Mon 14 Oct 2013 10:54:59 BST */

@magicmb
Copy link

magicmb commented Jan 29, 2020

I too was struggling to get my head around all these empty marker popups I was getting until I gave up on the whole idea of triggering popups via the oms 'click' event listener altogether and suddenly all previously created Leaflet popups using bindPopup simply started to work out of the box alongside the oms Leaflet plugin.

Not sure if this was some sort of conflict as I already had created popups using bindPopup prior to adding oms & the sample event click code, but it works great for me now so I didn't feel the need to investigate further.


For the record the behaviour I experienced before commenting out the oms 'click' code was as follows:

  • Various markers loaded on map some of which had overlaying markers spiderfied
  • Clicking spiderfied marker expanded underlying markers & displayed a valid popup
  • Clicking on any of the other expanded markers produced an empty popup
  • Clicking back on the initially loaded marker subsequently produced an empty marker


Commenting out the oms listener 'click' code fixed the popup issue in my case.

var topographic = L.esri.basemapLayer('Topographic'),
var layer = L.layerGroup([]);
var map = L.map('map', { center: [52.2993, 5.1628], zoom: 13, maxZoom: 17, layers: [topographic, layer], fullscreenControl: true, fullscreenControlOptions: { position: 'topleft' } });

var oms = new OverlappingMarkerSpiderfier(map, { keepSpiderfied: true });

// var popup = new L.Popup({closeButton: false, offset: new L.Point(0.5, -24)});
oms.addListener('click', function(marker) {
  /* popup.setContent(marker.desc);
  popup.setLatLng(marker.getLatLng());
  map.openPopup(popup); */
});

var redMarker = L.AwesomeMarkers.icon({ prefix: 'fa', icon: 'circle', markerColor: 'red', iconColor: 'white'});

for (var i = 0; i < window.mapData.length; i ++) {
  var marker = L.marker(mapData.[lat, mapData.lon], {icon:redMarker}).bindPopup(mapData.title+mapData.description);
  marker.addTo(map);
  layer.addLayer(marker);
  oms.addMarker(marker);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants