Giter VIP home page Giter VIP logo

Comments (9)

vogdb avatar vogdb commented on July 17, 2024

Thanks for the report! I will have time for this only on the weekend =(

from leaflet.activelayers.

vogdb avatar vogdb commented on July 17, 2024

@petemills I have now only one map overlay configuration. The Clouds from TestLayers.js. Can you please share with me the Overlay map configurations that you use? It would be very nice to have them in the format of TestLayers.js as the Clouds are:

  this.clouds = {
    name: 'Clouds',
    layer: L.tileLayer(
        'http://{s}.tile.openweathermap.org/map/clouds/{z}/{x}/{y}.png', {
          attribution: 'Map data &copy; <a href="http://openweathermap.org">OpenWeatherMap</a>'
          , opacity: 0.5
        }
    )
  }

from leaflet.activelayers.

petemills avatar petemills commented on July 17, 2024

Hey, unfortunately, I can't share the layers I'm working with as they're confidential, sorry :(. This should occur with any set of overlay layers though. If it's any consolation; I've managed to do what I was trying to do without having to use this functionality and what I was trying to do might be an incorrect use of the plugin, rather than a bug/issue!

from leaflet.activelayers.

vogdb avatar vogdb commented on July 17, 2024

Hi! Sorry that I returned so lately to the issue. There are still some thing to clarify. Please explain to me what the onadd event did you mean? As I can see now there are only two places in Leaflet that can fire such event: L.Marker and L.Path.
How can I attach to the event, that you've meant?

from leaflet.activelayers.

vogdb avatar vogdb commented on July 17, 2024

@petemills ?

from leaflet.activelayers.

petemills avatar petemills commented on July 17, 2024

Hi, sorry for not responding. I completely forgot! I found a way around this in the end (using a completely different method) and can't remember exactly what I was doing! I believe the onadd was fired simply when I added a marker to the map. I then wanted to push that new layer (marker) into an array to store it's position relative to other layers.

Thing is, every time I added a marker and the onadd function fired, getActiveLayers() was called. My question was: is that function asynchronous because it seemed that the rest of the function (pushing the layer into the array) carried on without the getActiveLayers() function returning. Not a problem anymore though let me know if you need any clarification.

Cheers.

from leaflet.activelayers.

quique0194 avatar quique0194 commented on July 17, 2024

I'm having a very similar problem:
I'm using a map with several overlay layers and saving the selected ones in the url. I have something like this:

map.on('overlayadd', function () {
    console.log(control.getActiveOverlayLayers());
});

The problem is that when you see the output of console.log, it's always on the previous state. I think it may be because the variable _activeOverlayLayers is being updated after the event's call. By the moment, my workaround is as follows:

map.on('overlayadd', function () {
    setTimeout(function () {
        console.log(control.getActiveOverlayLayers());
    }, 1);
});

from leaflet.activelayers.

vogdb avatar vogdb commented on July 17, 2024

@petemills @quique0194 please verify.

from leaflet.activelayers.

quique0194 avatar quique0194 commented on July 17, 2024

It works! Thanks

from leaflet.activelayers.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.