pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <legend id='67iRg'><style id='67iRg'><dir id='67iRg'><q id='67iRg'></q></dir></style></legend>
    <tfoot id='67iRg'></tfoot>

    <small id='67iRg'></small><noframes id='67iRg'>

      <bdo id='67iRg'></bdo><ul id='67iRg'></ul>
    1. <i id='67iRg'><tr id='67iRg'><dt id='67iRg'><q id='67iRg'><span id='67iRg'><b id='67iRg'><form id='67iRg'><ins id='67iRg'></ins><ul id='67iRg'></ul><sub id='67iRg'></sub></form><legend id='67iRg'></legend><bdo id='67iRg'><pre id='67iRg'><center id='67iRg'></center></pre></bdo></b><th id='67iRg'></th></span></q></dt></tr></i><div class="ll8bluc" id='67iRg'><tfoot id='67iRg'></tfoot><dl id='67iRg'><fieldset id='67iRg'></fieldset></dl></div>

      使傳單工具提示可點擊

      Making Leaflet tooltip clickable(使傳單工具提示可點擊)
        • <bdo id='IOw9k'></bdo><ul id='IOw9k'></ul>
              <tfoot id='IOw9k'></tfoot>

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

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

                <tbody id='IOw9k'></tbody>

                <legend id='IOw9k'><style id='IOw9k'><dir id='IOw9k'><q id='IOw9k'></q></dir></style></legend>
                本文介紹了使傳單工具提示可點擊的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我想在 Leaflet 地圖(不帶標記)上添加 工具提示 并使其可點擊.以下代碼添加了一個工具提示,但它不可點擊:

                I want to add tooltips on a Leaflet map (without markers) and make them clickable. The following code adds a tooltip but it's not clickable:

                var tooltip = L.tooltip({
                        direction: 'center',
                        permanent: true,
                        interactive: true,
                        noWrap: true,
                        opacity: 0.9
                    });
                tooltip.setContent( "Example" );
                tooltip.setLatLng(new L.LatLng(someLat, someLon));
                tooltip.addTo(myLayer);
                tooltip.on('click', function(event) {
                    console.log("Click!");
                });
                

                我怎樣才能讓它工作?

                推薦答案

                要接收對 L.Tooltip 對象的點擊,您需要:

                To receive clicks on a L.Tooltip object, you'll need to :

                • 在關聯的 DOM 對象上設置監聽器:

                • set up a listener on the associated DOM object :

                var el = tooltip.getElement();
                el.addEventListener('click', function() {
                   console.log("click");
                });
                

              • 刪除 pointer-events: none 在該元素上設置的屬性:

              • remove the pointer-events: none property set on that element:

                var el = tooltip.getElement();
                el.style.pointerEvents = 'auto';
                

              • 到目前為止的演示

                var map = L.map(document.getElementById('map')).setView([48.8583736, 2.2922926], 4);
                L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
                        attribution: '&copy; <a >OpenStreetMap</a> contributors'
                }).addTo(map);
                
                var tooltip = L.tooltip({
                    direction: 'center',
                    permanent: true,
                    interactive: true,
                    noWrap: true,
                    opacity: 0.9
                });
                tooltip.setContent( "Example" );
                tooltip.setLatLng(new L.LatLng(48.8583736, 2.2922926));
                tooltip.addTo(map);
                
                var el = tooltip.getElement();
                el.addEventListener('click', function() {
                    console.log("click");
                });
                el.style.pointerEvents = 'auto';

                html, body {
                  height: 100%;
                  margin: 0;
                }
                #map {
                  width: 100%;
                  height: 180px;
                }

                <link rel="stylesheet" />
                <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.js"></script>
                   
                <div id='map'></div>

                如果您想創建組件或直接監聽工具提示對象,您可以擴展 L.Tooltip 以將這些更改直接烘焙到定義中:

                If you want to create a component or listen directly to a tooltip object, you can extend L.Tooltip to bake those alterations directly into the definition:

                L.ClickableTooltip = L.Tooltip.extend({
                    onAdd: function (map) {
                        L.Tooltip.prototype.onAdd.call(this, map);
                
                        var el = this.getElement(),
                            self = this;
                
                        el.addEventListener('click', function() {
                            self.fire("click");
                        });
                        el.style.pointerEvents = 'auto';
                    }
                });
                
                var tooltip = new L.ClickableTooltip({
                    direction: 'center',
                    permanent: true,
                    noWrap: true,
                    opacity: 0.9
                });
                tooltip.setContent( "Example" );
                tooltip.setLatLng(new L.LatLng(48.8583736, 2.2922926));
                tooltip.addTo(map);
                
                tooltip.on('click', function(e) {
                    console.log("clicked", JSON.stringify(e.target.getLatLng()));
                });
                

                還有一個演示

                L.ClickableTooltip = L.Tooltip.extend({
                
                    onAdd: function (map) {
                        L.Tooltip.prototype.onAdd.call(this, map);
                
                        var el = this.getElement(),
                            self = this;
                
                        el.addEventListener('click', function() {
                            self.fire("click");
                        });
                        el.style.pointerEvents = 'auto';
                    }
                });
                
                
                var map = L.map(document.getElementById('map')).setView([48.8583736, 2.2922926], 4);
                L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
                        attribution: '&copy; <a >OpenStreetMap</a> contributors'
                }).addTo(map);
                
                var tooltip = new L.ClickableTooltip({
                    direction: 'center',
                    permanent: true,
                    noWrap: true,
                    opacity: 0.9
                });
                tooltip.setContent( "Example" );
                tooltip.setLatLng(new L.LatLng(48.8583736, 2.2922926));
                tooltip.addTo(map);
                
                tooltip.on('click', function(e) {
                    console.log("clicked", JSON.stringify(e.target.getLatLng()));
                });

                html, body {
                  height: 100%;
                  margin: 0;
                }
                #map {
                  width: 100%;
                  height: 180px;
                }

                <link rel="stylesheet" />
                <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.js"></script>
                   
                <div id='map'></div>

                這篇關于使傳單工具提示可點擊的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Check if a polygon point is inside another in leaflet(檢查一個多邊形點是否在傳單中的另一個內部)
                Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標記群集圖標顏色,繼承其余默認 CSS 屬性)
                Trigger click on leaflet marker(觸發點擊傳單標記)
                How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認加載磁貼顏色?)
                Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側邊欄)
                Leaflet - get latitude and longitude of a marker inside a pop-up(Leaflet - 在彈出窗口中獲取標記的緯度和經度)
                        <tbody id='r0gRC'></tbody>
                    • <i id='r0gRC'><tr id='r0gRC'><dt id='r0gRC'><q id='r0gRC'><span id='r0gRC'><b id='r0gRC'><form id='r0gRC'><ins id='r0gRC'></ins><ul id='r0gRC'></ul><sub id='r0gRC'></sub></form><legend id='r0gRC'></legend><bdo id='r0gRC'><pre id='r0gRC'><center id='r0gRC'></center></pre></bdo></b><th id='r0gRC'></th></span></q></dt></tr></i><div class="3mpgy8q" id='r0gRC'><tfoot id='r0gRC'></tfoot><dl id='r0gRC'><fieldset id='r0gRC'></fieldset></dl></div>
                      <tfoot id='r0gRC'></tfoot>

                        <bdo id='r0gRC'></bdo><ul id='r0gRC'></ul>

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

                          <legend id='r0gRC'><style id='r0gRC'><dir id='r0gRC'><q id='r0gRC'></q></dir></style></legend>

                        1. 主站蜘蛛池模板: 掺铥光纤放大器-C/L波段光纤放大器-小信号光纤放大器-合肥脉锐光电技术有限公司 | 脉冲除尘器,除尘器厂家-淄博机械 | 超声波成孔成槽质量检测仪-压浆机-桥梁预应力智能张拉设备-上海硕冠检测设备有限公司 | 铁艺,仿竹,竹节,护栏,围栏,篱笆,栅栏,栏杆,护栏网,网围栏,厂家 - 河北稳重金属丝网制品有限公司 山东太阳能路灯厂家-庭院灯生产厂家-济南晟启灯饰有限公司 | 3d打印服务,3d打印汽车,三维扫描,硅胶复模,手板,快速模具,深圳市精速三维打印科技有限公司 | 大流量卧式砂磨机_强力分散机_双行星双动力混合机_同心双轴搅拌机-莱州市龙跃化工机械有限公司 | 网带通过式抛丸机,,网带式打砂机,吊钩式,抛丸机,中山抛丸机生产厂家,江门抛丸机,佛山吊钩式,东莞抛丸机,中山市泰达自动化设备有限公司 | 高楼航空障碍灯厂家哪家好_航空障碍灯厂家_广州北斗星障碍灯有限公司 | 工业PH计|工业ph酸度计|在线PH计价格-合肥卓尔仪器仪表有限公司 济南画室培训-美术高考培训-山东艺霖艺术培训画室 | 建大仁科-温湿度变送器|温湿度传感器|温湿度记录仪_厂家_价格-山东仁科 | 档案密集架_电动密集架_移动密集架_辽宁档案密集架-盛隆柜业厂家现货批发销售价格公道 | 液氨泵,液化气泵-淄博「亚泰」燃气设备制造有限公司 | 山东风淋室_201/304不锈钢风淋室净化设备厂家-盛之源风淋室厂家 翻斗式矿车|固定式矿车|曲轨侧卸式矿车|梭式矿车|矿车配件-山东卓力矿车生产厂家 | 专注氟塑料泵_衬氟泵_磁力泵_卧龙泵阀_化工泵专业品牌 - 梭川泵阀 | 天津中都白癜风医院_天津白癜风医院_天津治疗白癜风 | 吉林污水处理公司,长春工业污水处理设备,净水设备-长春易洁环保科技有限公司 | 尼龙PA610树脂,尼龙PA612树脂,尼龙PA1010树脂,透明尼龙-谷骐科技【官网】 | BESWICK球阀,BESWICK接头,BURKERT膜片阀,美国SEL继电器-东莞市广联自动化科技有限公司 | 塑料造粒机「厂家直销」-莱州鑫瑞迪机械有限公司 | 上海刑事律师|刑事辩护律师|专业刑事犯罪辩护律师免费咨询-[尤辰荣]金牌上海刑事律师团队 | 不锈钢搅拌罐_高速搅拌罐厂家-无锡市凡格德化工装备科技有限公司 | 楼承板设备-楼承板成型机-免浇筑楼承板机器厂家-捡来 | 蒸压釜-陶粒板隔墙板蒸压釜-山东鑫泰鑫智能装备有限公司 | 西门子伺服控制器维修-伺服驱动放大器-828D数控机床维修-上海涌迪 | 全自动变压器变比组别测试仪-手持式直流电阻测试仪-上海来扬电气 | 北京公寓出租网-北京酒店式公寓出租平台 | 磁力抛光机_磁力研磨机_磁力去毛刺机_精密五金零件抛光设备厂家-冠古科技 | Dataforth隔离信号调理模块-信号放大模块-加速度振动传感器-北京康泰电子有限公司 | 德国BOSCH电磁阀-德国HERION电磁阀-JOUCOMATIC电磁阀|乾拓百科 | 活性氧化铝球|氧化铝干燥剂|分子筛干燥剂|氢氧化铝粉-淄博同心材料有限公司 | 重庆私家花园设计-别墅花园-庭院-景观设计-重庆彩木园林建设有限公司 | 香港新时代国际美容美发化妆美甲培训学校-26年培训经验,值得信赖! | 丙烷/液氧/液氮气化器,丙烷/液氧/液氮汽化器-无锡舍勒能源科技有限公司 | 密集柜_档案密集柜_智能密集架_密集柜厂家_密集架价格-智英伟业 密集架-密集柜厂家-智能档案密集架-自动选层柜订做-河北风顺金属制品有限公司 | 施工电梯_齿条货梯_烟囱电梯_物料提升机-河南大诚机械制造有限公司 | 量子管通环-自清洗过滤器-全自动反冲洗过滤器-沼河浸过滤器 | 衬四氟_衬氟储罐_四氟储罐-无锡市氟瑞特防腐科技有限公司 | 东莞螺丝|东莞螺丝厂|东莞不锈钢螺丝|东莞组合螺丝|东莞精密螺丝厂家-东莞利浩五金专业紧固件厂家 | 杜康白酒加盟_杜康酒代理_杜康酒招商加盟官网_杜康酒厂加盟总代理—杜康酒神全国运营中心 | 成都治疗尖锐湿疣比较好的医院-成都治疗尖锐湿疣那家医院好-成都西南皮肤病医院 | 派财经_聚焦数字经济内容服务平台 |