1. <small id='KTX19'></small><noframes id='KTX19'>

  2. <i id='KTX19'><tr id='KTX19'><dt id='KTX19'><q id='KTX19'><span id='KTX19'><b id='KTX19'><form id='KTX19'><ins id='KTX19'></ins><ul id='KTX19'></ul><sub id='KTX19'></sub></form><legend id='KTX19'></legend><bdo id='KTX19'><pre id='KTX19'><center id='KTX19'></center></pre></bdo></b><th id='KTX19'></th></span></q></dt></tr></i><div id='KTX19'><tfoot id='KTX19'></tfoot><dl id='KTX19'><fieldset id='KTX19'></fieldset></dl></div>
      <bdo id='KTX19'></bdo><ul id='KTX19'></ul>
      <tfoot id='KTX19'></tfoot>
    1. <legend id='KTX19'><style id='KTX19'><dir id='KTX19'><q id='KTX19'></q></dir></style></legend>
    2. 在传单中设置图层的缩放级别

      时间:2023-08-08

      <small id='DmOEp'></small><noframes id='DmOEp'>

      <legend id='DmOEp'><style id='DmOEp'><dir id='DmOEp'><q id='DmOEp'></q></dir></style></legend>
        <tbody id='DmOEp'></tbody>

            • <i id='DmOEp'><tr id='DmOEp'><dt id='DmOEp'><q id='DmOEp'><span id='DmOEp'><b id='DmOEp'><form id='DmOEp'><ins id='DmOEp'></ins><ul id='DmOEp'></ul><sub id='DmOEp'></sub></form><legend id='DmOEp'></legend><bdo id='DmOEp'><pre id='DmOEp'><center id='DmOEp'></center></pre></bdo></b><th id='DmOEp'></th></span></q></dt></tr></i><div id='DmOEp'><tfoot id='DmOEp'></tfoot><dl id='DmOEp'><fieldset id='DmOEp'></fieldset></dl></div>
              <tfoot id='DmOEp'></tfoot>
              • <bdo id='DmOEp'></bdo><ul id='DmOEp'></ul>
                本文介绍了在传单中设置图层的缩放级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                从这里继续查询:

                解决方案

                我找到了一个解决方案,我们可以用更短和更长(虽然更实用)的方式来解释:

                根据下面的例子:

                https://gis.stackexchange.com/questions/258515/show-hide-markers-depending-on-zoom-level

                我们可以这样做:

                 map.on('zoomend', function() {if (map.getZoom() <6){map.removeLayer(job);//第一个 geoJSON 层}别的{map.addLayer(工作);}if (map.getZoom() <7){map.removeLayer(job2);//第二个geoJSON层}别的{map.addLayer(job2);}if (map.getZoom() <8){map.removeLayer(job3);//第三个geoJSON层}别的{map.addLayer(job3);}});

                这对我们来说更好,不像较短的......

                 map.on('zoomend', function() {if (map.getZoom() <6){map.removeLayer(job);//第一个 geoJSON 层}if (map.getZoom() <8){map.removeLayer(job2);//第二个geoJSON层}if (map.getZoom() <10){map.removeLayer(job3);//第三个geoJSON层}别的 {map.addLayer(工作);map.addLayer(job2);map.addLayer(job3);}//所有图层都被打开,当缩放级别达到10});

                当缩放级别达到函数中给定的最大值时,可以将所有图层切换回来.

                Continuing the query from here:

                https://gis.stackexchange.com/questions/340223/leaflet-making-features-gone-when-zoom-out

                I would like to have some layers completely gone when zooming out.

                I tried sth like this:

                 map.on('zoomend', function (e) {
                  zoom_based_layerchange();
                 });
                
                 function clean_map() {
                 map.eachLayer(function (layer) {
                 if (layer instanceof L.GeoJSON)
                {
                    map.removeLayer(layer);
                 }
                //console.log(layer);
                 });
                 }
                
                 function zoom_based_layerchange() {
                //console.log(map.getZoom());
                
                  var currentZoom = map.getZoom();
                   switch (currentZoom) {
                case 8:     //refers to the zoom level: 8
                    clean_map();
                    sitis.addTo(map); //show "sitis" geoJSON layer
                    break;
                case 12:
                    //clean_map(); - removed, as I don't need to remove the layer visible at lower zoom level
                    church.addTo(map);   //show "church" geoJSON layer
                    break;
                default:
                    // do nothing
                    break;
                

                } }

                but unfortunately it isn't a thing, which I am looking for, because once one layer disappear, another one is coming in. Eventually, the very top layer remain still visible when zooming out to level 1 as per the example here:

                http://jsfiddle.net/expedio/kuovyw8m/

                Because I would like to have layers gone as zoom out I tried sth like this:

                 map.on('zoomend', function () {
                   if (map.getZoom() < 10 {
                    map.removeLayer(sitec);
                   }
                   if (map.getZoom() < 12 {
                    map.removeLayer(test);
                   }
                   else {
                    map.addLayerGroup([sitec,test]);
                    }
                });
                

                it doesn't work completely. COnsole says:

                Uncaught SyntaxError: Unexpected token '{' which is a contradiction to the example here:

                https://gis.stackexchange.com/questions/258515/show-hide-markers-depending-on-zoom-level

                in other case I have:

                Uncaught TypeError: sitec.removeFrom is not a function at i. ((index):174) at i.fire (leaflet.js:5) at i._moveEnd (leaflet.js:5) at i. (leaflet.js:5)

                when type code like this:

                 map.on('zoomend', function () {
                 var z = map.getZoom();
                
                 if (z > 12) {
                 return sitec.addTo(map);
                 }
                
                 if (z > 14) {
                 return test.addTo(map);
                 }
                
                 return sitec.removeFrom(map);
                 });
                

                as per the example here:

                https://gis.stackexchange.com/questions/182657/zoom-dependent-layers-in-leaflet

                Last thing which I tried was the plugin available here:

                https://github.com/auto-mat/leaflet-zoom-show-hide/blob/master/demo.html

                Where I put:

                    zsh = new ZoomShowHide();
                    zsh.addTo(map);
                    sitec.min_zoom = 9;
                    zsh.addLayer(sitec);
                    test.min_zoom = 11;
                    zsh.addLayer(test);
                

                but still wothiut result. The console says:

                uncaught TypeError: layer.addTo is not a function -> from leaflet-zoom-hide 21 layer.addTo(this._layerGroup);

                Does anyone know how to deal with it?

                My code is available here:

                解决方案

                I found one of the solution, that we can explain by shorter and longer (although more practical) way:

                According to the example below:

                https://gis.stackexchange.com/questions/258515/show-hide-markers-depending-on-zoom-level

                We can do sth like this:

                  map.on('zoomend', function() {
                  if (map.getZoom() <6){
                    map.removeLayer(job);//1st geoJSON layer
                   }else{
                  map.addLayer(job);
                   }
                    if (map.getZoom() <7){
                    map.removeLayer(job2); //2nd geoJSON layer
                    }else{
                    map.addLayer(job2);
                    }
                    if (map.getZoom() <8){
                    map.removeLayer(job3); //3rd geoJSON layer
                    }else{
                    map.addLayer(job3);
                    }
                  });
                

                which is better for us, unlike to shorter one...

                  map.on('zoomend', function() {
                    if (map.getZoom() <6){
                    map.removeLayer(job);//1st geoJSON layer
                   }
                   if (map.getZoom() <8){
                    map.removeLayer(job2);//2nd geoJSON layer
                   }
                   if (map.getZoom() <10){
                    map.removeLayer(job3);//3rd geoJSON layer
                   }
                   else {
                    map.addLayer(job);
                    map.addLayer(job2);
                    map.addLayer(job3);
                    } //all layers are to be switched on, when zoom level reach 10
                   });
                

                that can switch all layers back when zoom level reach max value given in the function.

                这篇关于在传单中设置图层的缩放级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:Leaflet - 将控件放在 div 地图之外 下一篇:TimeSlider 插件和传单 - 标记未按顺序显示

                相关文章

                最新文章

                  <tfoot id='aSsLM'></tfoot>

                1. <legend id='aSsLM'><style id='aSsLM'><dir id='aSsLM'><q id='aSsLM'></q></dir></style></legend>
                  <i id='aSsLM'><tr id='aSsLM'><dt id='aSsLM'><q id='aSsLM'><span id='aSsLM'><b id='aSsLM'><form id='aSsLM'><ins id='aSsLM'></ins><ul id='aSsLM'></ul><sub id='aSsLM'></sub></form><legend id='aSsLM'></legend><bdo id='aSsLM'><pre id='aSsLM'><center id='aSsLM'></center></pre></bdo></b><th id='aSsLM'></th></span></q></dt></tr></i><div id='aSsLM'><tfoot id='aSsLM'></tfoot><dl id='aSsLM'><fieldset id='aSsLM'></fieldset></dl></div>

                    <small id='aSsLM'></small><noframes id='aSsLM'>

                    • <bdo id='aSsLM'></bdo><ul id='aSsLM'></ul>