Giter VIP home page Giter VIP logo

Comments (10)

stuggi05 avatar stuggi05 commented on August 21, 2024

That would be very nice.

btw Is it possible to define the deafult base layer in an easy way in the .js-file?

from lizmap-plugin.

nboisteault avatar nboisteault commented on August 21, 2024

Here is what I changed in lizmap/www/js/map.js :

Basemap names are : Google Streets, osm, ignphoto for example.

ORIGINAL :

    // get the baselayer select content
    // and adding baselayers to the map
    //var select = '<select class="baselayers">';
    var select = [];
    baselayers.reverse();
    for (var i=0,len=baselayers.length; i<len; i++) {
      var baselayer = baselayers[i]
      baselayer.units = projection.proj.units;
      map.addLayer(baselayer);
      var blConfig = config.layers[baselayer.name];
      if (blConfig)
        select += '<option value="'+blConfig.name+'">'+blConfig.title+'</option>';
      else
        select += '<option value="'+baselayer.name+'">'+baselayer.name+'</option>';
      /*
      if (blConfig)
        select.push('<input type="radio" name="baselayers" value="'+blConfig.name+'"><span class="baselayer-radio-label">'+blConfig.title+'</span></input>');
      else
        select.push('<input type="radio" name="baselayers" value="'+baselayer.name+'"><span class="baselayer-radio-label">'+baselayer.name+'</span></input>');
        */
    }

MODIFIED :

    // get the baselayer select content
    // and adding baselayers to the map
    //var select = '<select class="baselayers">';
    var select = [];
    baselayers.reverse();
    for (var i=0,len=baselayers.length; i<len; i++) {
      var baselayer = baselayers[i]
      baselayer.units = projection.proj.units;
      map.addLayer(baselayer);

      var selected = '';

      if(capabilities.service.title=='YOUR PROJECT TITLE' && baselayer.name=='YOUR BASEMAP NAME'){
        selected = 'selected';
        map.setBaseLayer(map.getLayersByName(baselayer.name)[0]);
      }

      var blConfig = config.layers[baselayer.name];
      if (blConfig)
        select += '<option value="'+blConfig.name+'" '+selected+'>'+blConfig.title+'</option>';
      else
        select += '<option value="'+baselayer.name+'" '+selected+'>'+baselayer.name+'</option>';

      /*
      if (blConfig)
        select.push('<input type="radio" name="baselayers" value="'+blConfig.name+'"><span class="baselayer-radio-label">'+blConfig.title+'</span></input>');
      else
        select.push('<input type="radio" name="baselayers" value="'+baselayer.name+'"><span class="baselayer-radio-label">'+baselayer.name+'</span></input>');
        */
    }

Of course it is better to use an external script or you'll have to report this hack when you'll update lizmap web cient.

from lizmap-plugin.

stuggi05 avatar stuggi05 commented on August 21, 2024

THX!!

from lizmap-plugin.

nboisteault avatar nboisteault commented on August 21, 2024

Though with that script I noticed that if you use a permalink with a different base layer than default you'll get the default base layer selected in combobox. I might take some time to fix this.

from lizmap-plugin.

josemvm avatar josemvm commented on August 21, 2024

Thanks!

it would be best to select through the plugin...

from lizmap-plugin.

nboisteault avatar nboisteault commented on August 21, 2024

Of course it would be best but it has to be developed.
@rldhont : what would cost the development of this feature? Maybe we can fund it with all interested people?

from lizmap-plugin.

josemvm avatar josemvm commented on August 21, 2024

yes it's true and of course you're right. so, It's a suggestion for the future!

from lizmap-plugin.

rldhont avatar rldhont commented on August 21, 2024

Fix in commit 15982a8 [FEATURE] Baselayers - Choose active baselayer at map startup

from lizmap-plugin.

pcav avatar pcav commented on August 21, 2024

Thanks. Any plans to backport it to 2.x?

from lizmap-plugin.

rldhont avatar rldhont commented on August 21, 2024

Done commit c875b1d2cf063a56769ab6e88878b8fa19cb14e8

from lizmap-plugin.

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.