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

Displaying popup details for a marker #58

Open
melcherbro opened this issue Feb 9, 2018 · 2 comments
Open

Displaying popup details for a marker #58

melcherbro opened this issue Feb 9, 2018 · 2 comments

Comments

@melcherbro
Copy link

melcherbro commented Feb 9, 2018

So I've been trying to get this to work with the bindPopup feature in leaflet once the data points are placed by I can't seem to get them to appear.

Currently I'm setting the data points as follows:

`var Circles = L.geoJSON(someFeatures, {
pointToLayer: function(feature, latlng) {
var col = getColor(feature);
return L.circle(latlng, {
color: col,
fillColor: col,
fillOpacity: .5,
opacity: .5,
radius: 2
});
},

onEachFeature: onEachFeature
});`

I'm displaying a few thousand points so the circles look better and perform better for me.

For the onEachFeature I'm simply just setting the pop up as follows:

function onEachFeature(feature, layer) { if (feature.properties && feature.properties.popupContent) { layer.bindPopup('test'); layer.on('mouseover', function(e) { this.openPopup(); }); } }

I had the popup being set to other things but this is my foolproof debugging mode, I know its brilliant.

So the problem I'm facing is that I'm not getting any sort of popup for a mouseover (or an click for that matter when I change the 'mouseover' to 'click'.

I know that I haven't lost the functionality to click the page because I created an event listener for:
`
mymap.on('click', function(){
alert('test');
});

`
And when I click on the map I still get a response so at least that layer is responding.

Now the current rabbit hole that I am down is that maybe because of the way that the slider creates a bunch of layers to display all the points its just overloading leaflet (keep in mind I'm dealing with thousands of points) or maybe the map is just being brought to the front and overriding the clicks (but I tried to move it to the back with mymap.bringToBack() with no change in functionality).

Just wondering if anyone else has managed to make this work/ has had a similar problem to me with this. I'll try it with a smaller data set to try and see if its a data size issue but I really don't think that's the case because you would think that the map layer would stop responding as well if that were the problem.

Also sorry about poor formatting (battery dying and I left my charger at work) I'll try and fix it tomorrow.

@geyerbri
Copy link

geyerbri commented Apr 30, 2020

For use with markers and popups (including custom icons), look at this commented html file file of my updated LeafletSlider. It's live at https://geyerbri.github.io/LeafletSlider/commented.html.

This commented.html provides in-line comments to walk through how to add markers with popups, and control them with the slider either individually, or in groups.

I've also written a step-by-step guide to explain how to use this module with geoJSON data.

(EDIT on 9/26/20 to update links and link to new tutorial)

@Falke-Design
Copy link

Hi @geyerbri you have done nice work. Maybe you can create a new fork/branche from my master and update your code to the branche and then make a pull request to my fork. This would remove the ton of not necessary commits in you current master branche.

Also your example is not working ;)

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

3 participants