Giter Club home page Giter Club logo

Comments (1)

nmccready avatar nmccready commented on July 20, 2024

From @pieterjandesmedt on December 18, 2014 13:15

You'll need to modify angular-leaflet-directive.js a bit for that. Right now, it checks if the layer exists (by name only) and then does nothing if the layer exists, even if its url has changed. Study lines 626-647 and 675-696 to understand. I modified it like this:

On line 628, change

     if (!isDefined(newBaseLayers[name])) {

into

     if (!isDefined(newBaseLayers[name]) || newBaseLayers[name].refresh) {

Likewise, change line 676 into

     if (!isDefined(newOverlayLayers[name]) || newOverlayLayers[name].refresh) {

In your initial layer configuration, add refresh: true like this:

layers: {
    baselayers: {
        myTileLayer: {
            name: 'My Changing Base Layer',
            url: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
            type: 'xyz',
            refresh: true
        }
    },
    overlays: {
        myOverlay: {
            name: 'My Changing Overlay',
            type: 'xyz',
            url: ...,
            visible: false,
            refresh: true
        },
    }

Then you can change the layer's url to http://tile.stamen.com/#toner/{z}/{x}/{y}.png after your first init. The watch will pick up the change and delete the layer then add it again with the new url if its refresh attribute is set to true.

from ui-leaflet.

Related Issues (20)

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.