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

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

    1. <legend id='j2LQr'><style id='j2LQr'><dir id='j2LQr'><q id='j2LQr'></q></dir></style></legend>
    2. <tfoot id='j2LQr'></tfoot>

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

      刷新传单地图:地图容器已经初始化

      时间:2023-05-28

          <tfoot id='Hm9fC'></tfoot>
            <tbody id='Hm9fC'></tbody>

          • <small id='Hm9fC'></small><noframes id='Hm9fC'>

          • <i id='Hm9fC'><tr id='Hm9fC'><dt id='Hm9fC'><q id='Hm9fC'><span id='Hm9fC'><b id='Hm9fC'><form id='Hm9fC'><ins id='Hm9fC'></ins><ul id='Hm9fC'></ul><sub id='Hm9fC'></sub></form><legend id='Hm9fC'></legend><bdo id='Hm9fC'><pre id='Hm9fC'><center id='Hm9fC'></center></pre></bdo></b><th id='Hm9fC'></th></span></q></dt></tr></i><div id='Hm9fC'><tfoot id='Hm9fC'></tfoot><dl id='Hm9fC'><fieldset id='Hm9fC'></fieldset></dl></div>

            <legend id='Hm9fC'><style id='Hm9fC'><dir id='Hm9fC'><q id='Hm9fC'></q></dir></style></legend>
              <bdo id='Hm9fC'></bdo><ul id='Hm9fC'></ul>

                本文介绍了刷新传单地图:地图容器已经初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我有一个页面,用户可以在其中选择他可以切换我显示的传单地图.

                I have a page where given a select to the user he can switch the leaflet map I show.

                在初始传单地图加载后,我的问题是何时我想刷新地图.

                After a initial leaflet map load, my problem is when i want to refresh the map.

                我总是得到地图容器已经初始化":

                I always get "Map container is already initialized":

                问题行是:

                var map = L.map('mapa').setView([lat, lon], 15);
                

                最初它加载得很好,但是当我在表单中选择另一个参数并想再次显示地图时它崩溃了.

                Initially it loads well, but when I select another parameter in the form and want to display the map another time it crashes.

                顺便说一句,我尝试在第二个 setView() 之前使用 jQuery 销毁和重新创建 $('#mapa') 但它显示相同的错误.

                btw, I've tried to destroy and recreate $('#mapa') with jQuery before the second setView() but it shows the same error.

                推荐答案

                Html:

                <div id="weathermap"></div>
                

                JavaScript:

                function buildMap(lat,lon)  {
                    document.getElementById('weathermap').innerHTML = "<div id='map' style='width: 100%; height: 100%;'></div>";
                    var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
                                    osmAttribution = 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors,' +
                                        ' <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
                    osmLayer = new L.TileLayer(osmUrl, {maxZoom: 18, attribution: osmAttribution});
                    var map = new L.Map('map');
                    map.setView(new L.LatLng(lat,lon), 9 );
                    map.addLayer(osmLayer);
                    var validatorsLayer = new OsmJs.Weather.LeafletLayer({lang: 'en'});
                    map.addLayer(validatorsLayer);
                }
                

                我用这个:

                document.getElementById('weathermap').innerHTML = "<div id='map' style='width: 100%; height: 100%;'></div>";
                

                在渲染地图的地方重新加载 div 的内容.

                to reload content of div where render map.

                这篇关于刷新传单地图:地图容器已经初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:传单不连贯地绘制瓷砖 下一篇:如何修复错误“编译失败:./node_modules/@react-leafl

                相关文章

                最新文章

              1. <small id='9B9ne'></small><noframes id='9B9ne'>

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