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

More than one marker in the same time #4

Open
00ricardo opened this issue Jul 4, 2020 · 1 comment
Open

More than one marker in the same time #4

00ricardo opened this issue Jul 4, 2020 · 1 comment

Comments

@00ricardo
Copy link

ello! Is there a way to display more data (markers) that share the same datetime?

It looks like it creates a "step slider" for each marker in the layerGroup. So ... to solve this, I did the following:

if (date.includes(layer.options.time)) {
            options.markers[index_temp] = layer;
        }
        else {
            options.markers[index_temp] = layer;
            date.push(layer.options.time)
            ++index_temp;
        }

I am manipulating the size of the slider if there are equal times. If the datetime exists it doesn't increase the size and if it doesn't exist it increases. And it worked!!
But now ... data that shares the same datetime is not displayed, just one marker instead of two (for example)! How can I make this work?

PS:
I have 2 layers (polygon and custom marker) with the same datetime : 04/07/2020 13:00:00, but only the polygon is displayed, I just want to displayed both at the same time.

image

@geyerbri
Copy link

Hey if you're still looking for a solution, it requires creating some kind of empty group (geoJSON, featureGroup, layerGroup, etc.), putting both the marker and polygon into it, setting that group's time option to the shared date, then adding that group to the group you're feeding to sliderControl:

var sameDateGroup =  L.layerGroup();

customMarker.addTo(sameDateGroup);
polygon.addTo(sameDateGroup);

sameDateGroup.options.time = "04/07/2020 13:00:00";

sameDateGroup.addTo(existingGroup);

If you're looking to control a bunch of groups this way (not just a one-time example), you could also do it by making a group for each set to appear at the same time, setting each group's designated time, loading them all into a layerGroup, then giving that layerGroup to sliderControl:

var group1 = L.geoJSON(data1);
var group2 = L.geoJSON(data2);
var group3 = L.geoJSON(data3);

group1.options.time = "1991";
group2.options.time = "1992";
group3.options.time = "1993";

var allGroups = L.layerGroup([group1, group2, group3]);

var sliderControl = L.control.sliderControl( {
                layer: allGroups;
});

Hope this helps.

I've also written an in-depth tutorial for using layerGroup along with markers, for when you want to attach popups to them and have multiple markers appear at the same time.

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