亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

地圖下背景錯誤(地圖背景有問題)

地圖下背景錯誤(地圖背景有問題)

米琪卡哇伊 2021-06-28 17:00:53
我是初級 Web 開發人員,我在使用 Open Street Map 時遇到問題:https : //ibb.co/x8mqR62我有這個代碼:<div id="mapdiv"></div>    <script type="text/javascript">        function onLocationFound(e) {            var radius = e.accuracy / 2;            lat = e.latlng.lat;            lng = e.latlng.lng;            L.marker(e.latlng).addTo(map).bindPopup("Tutaj jeste?!!!");            //L.circle(e.latlng, radius).addTo(map);            map.setView([lat, lng], 12);        }        function onLocationError(e) {            //alert(e.message);            console.log(e.message);        }        var map = L.map('mapdiv', {            editable: true,            fadeAnimation: false        }).setView([54.35070881441067, 18.641191756395074], 12);        L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', {        // L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', {                attribution: '&copy; <a href="https://osm.org/copyright">OpenStreetMap</a> contributors',                maxZoom: 18, zoomControl: true, detectRetina: true            }).addTo(map);            let myFilter = ['grayscale:100%'];            let myTileLayer = L.tileLayer.colorFilter('https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png', {                attribution: '<a href="https://wikimediafoundation.org/wiki/Maps_Terms_of_Use">Wikimedia</a>',                filter: myFilter,            }).addTo(map);            // lc = L.control.locate({            //     strings: {            //         title: "Poka? gdzie jestem"            //     }            // }).addTo(map);            var LeafIcon = L.Icon.extend({                options: {                    iconSize: [25, 29],                    iconAnchor: [25, 29],                    popupAnchor: [-12, -22]                }            });這個地圖工作正常,但我的問題是灰色背景。我的地圖在線預覽:http : //serwer1356363.home.pl/pub/test/mapa.html如何刪除灰色背景并顯示正常的彩色地圖?
查看完整描述

2 回答

?
慕桂英546537

TA貢獻1848條經驗 獲得超10個贊

這是 Leaflet 的常見問題。一種解決方案是使用window.dispatchEvent()

window.dispatchEvent(new Event('resize'));

調度窗口調整大小事件,該事件讀取地圖容器大小并在頁面加載時相應地調整窗格。


查看完整回答
反對 回復 2021-07-08
?
波斯汪

TA貢獻1811條經驗 獲得超4個贊

您需要刪除該grayscale屬性或將其更改為0.

所以改變這個... <div class="leaflet-layer" style="z-index: 1; filter: grayscale(100%);">

對此 <div class="leaflet-layer" style="z-index: 1;">

或者如果您無法內聯更改它,請在您的 CSS 中嘗試此操作... .leaflet-layer { filter: grayscale(0); }


查看完整回答
反對 回復 2021-07-08
  • 2 回答
  • 0 關注
  • 258 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號