日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Leaflet工作笔记-多个标签在地图显示不关闭

發(fā)布時間:2025/3/15 编程问答 15 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Leaflet工作笔记-多个标签在地图显示不关闭 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

就是這個例子:

網(wǎng)頁一進去就是被打開的。并且多個標(biāo)簽同時顯示。

要實現(xiàn)這種效果,需要如下設(shè)置:

1.設(shè)置bindPopup時把autoClose設(shè)置為false,這樣點開一個就不會關(guān)閉另外一個了。

2.在所有腳本設(shè)置好了,通過fire函數(shù)傳入'click',再指定坐標(biāo),可以在頁面加載后,就顯示了。

源碼如下:

<!DOCTYPE html> <html> <head><title>Quick Start - Leaflet</title><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" /><link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin=""/><script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js" integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew==" crossorigin=""></script><script src="https://cdn.bootcss.com/echarts/4.4.0-rc.1/echarts.min.js"></script><script src="https://www.echartsjs.com/examples/vendors/echarts-gl/echarts-gl.js"></script></head> <body><div id="mapid" style="width: 600px; height: 400px;"></div> <script>var mymap = L.map('mapid').setView([51.505, -0.09], 13);L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {maxZoom: 18,attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +'Imagery ? <a href="https://www.mapbox.com/">Mapbox</a>',id: 'mapbox/streets-v11'}).addTo(mymap);//L.marker([51.5, -0.09]).addTo(mymap).bindPopup("<b>Hello world!</b><br />I am a popup.").openPopup();let popupContent = '<div style="width:200px;height:200px" id="popupTest"</div>';let testLay = L.circleMarker([51.5,-0.09],{radius: 8,fillColor: "#ff7800",color: "#000",weight: 1,opacity: 1,fillOpacity: 0.8}).addTo(mymap);testLay.bindPopup(popupContent, {autoClose: false});let popupContent2 = '<div style="width:200px;height:200px" id="popupTest2"</div>';let testLay2 = L.circleMarker([51.5,-0.08],{radius: 8,fillColor: "#ff7800",color: "#000",weight: 1,opacity: 1,fillOpacity: 0.8,}).addTo(mymap);testLay2.bindPopup(popupContent2, {autoClose: false});testLay.on('popupopen', function (e) {var myChart = echarts.init(document.getElementById('popupTest'));let hours = [ '1a', '2a', '3a', '4a', '5a'];let days = ['Saturday'];let option = {xAxis3D: {type: 'category',data: hours},yAxis3D: {type: 'category',data: days},zAxis3D: {type: 'value'},grid3D: {viewControl: {// autoRotate: true},light: {main: {shadow: true,quality: 'ultra',intensity: 1.5}}},tooltip: {},legend: {data: ['一檔', '二檔','三檔','四檔','五檔']},series: [{type: 'bar3D',name: "一檔",data: [[0, 2, 20], [1, 2, 2], [2, 2, 2], [3, 2, 2], [4, 2, 2]],stack: 'stack',shading: 'lambert',emphasis: {label: {show: true}}},{type: 'bar3D',name: "二檔",data: [[0, 2, 2], [1, 2, 20], [2, 2, 2], [3, 2, 2], [4, 2, 2]],stack: 'stack',shading: 'lambert',emphasis: {label: {show: false}}}]}myChart.setOption(option);});testLay2.on('popupopen', function (e) {var myChart = echarts.init(document.getElementById('popupTest2'));let hours = [ '1a', '2a', '3a', '4a', '5a'];let days = ['Saturday'];let option = {xAxis3D: {type: 'category',data: hours},yAxis3D: {type: 'category',data: days},zAxis3D: {type: 'value'},grid3D: {viewControl: {// autoRotate: true},light: {main: {shadow: true,quality: 'ultra',intensity: 1.5}}},tooltip: {},legend: {data: ['一檔', '二檔','三檔','四檔','五檔']},series: [{type: 'bar3D',name: "一檔",data: [[0, 2, 20], [1, 2, 2], [2, 2, 2], [3, 2, 2], [4, 2, 2]],stack: 'stack',shading: 'lambert',emphasis: {label: {show: true}}},{type: 'bar3D',name: "二檔",data: [[0, 2, 2], [1, 2, 20], [2, 2, 2], [3, 2, 2], [4, 2, 2]],stack: 'stack',shading: 'lambert',emphasis: {label: {show: false}}}]}myChart.setOption(option);});testLay.fire('click', {latlng: [51.5,-0.09]});testLay2.fire('click', {latlng: [51.5,-0.08]});</script></body>

?

總結(jié)

以上是生活随笔為你收集整理的Leaflet工作笔记-多个标签在地图显示不关闭的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。