久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <bdo id='2hXWR'></bdo><ul id='2hXWR'></ul>

<legend id='2hXWR'><style id='2hXWR'><dir id='2hXWR'><q id='2hXWR'></q></dir></style></legend>

    <small id='2hXWR'></small><noframes id='2hXWR'>

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

    1. Leaflet.contextmenu 回調

      Leaflet.contextmenu callbacks(Leaflet.contextmenu 回調)

          <tbody id='XqtL6'></tbody>
          1. <tfoot id='XqtL6'></tfoot>
          2. <legend id='XqtL6'><style id='XqtL6'><dir id='XqtL6'><q id='XqtL6'></q></dir></style></legend>
            • <small id='XqtL6'></small><noframes id='XqtL6'>

                <bdo id='XqtL6'></bdo><ul id='XqtL6'></ul>
                <i id='XqtL6'><tr id='XqtL6'><dt id='XqtL6'><q id='XqtL6'><span id='XqtL6'><b id='XqtL6'><form id='XqtL6'><ins id='XqtL6'></ins><ul id='XqtL6'></ul><sub id='XqtL6'></sub></form><legend id='XqtL6'></legend><bdo id='XqtL6'><pre id='XqtL6'><center id='XqtL6'></center></pre></bdo></b><th id='XqtL6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='XqtL6'><tfoot id='XqtL6'></tfoot><dl id='XqtL6'><fieldset id='XqtL6'></fieldset></dl></div>
                本文介紹了Leaflet.contextmenu 回調的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在努力解決 Leaflet.contextmenu 庫中的問題.

                I'm struggling with a problem in the Leaflet.contextmenu library.

                我有許多不同的地圖,保存在一個全局數組中.然后我使用 contextmenu 選項在我的地圖中有一個 contextmenu.當我想定義我的回調函數時,我無法訪問我的 arrMap[id],因為該函數不知道我正在使用的 id.

                I got a number of different maps, saved in a global Array. Then I'm using the contextmenu options to have a contextmenu in my maps. When I want to define my callback functions, I can't access my arrMap[id], because the function doesn't know the id I'm using.

                我的問題是:如何將對象(例如 id)放入 Leaflet.contextmenu 庫的回調函數中?

                My question here is: How can I give an object (the id, for example) into a callback function of the Leaflet.contextmenu library?

                function x(){
                    arrMap[id] = new L.map('map'+id,{
                        contextmenu: true,
                        contextmenuWidth: 140,
                        contextmenuItems: [{
                            text: 'Messung an dieser Position einfügen',
                            callback: newMeasurement
                        }, {
                            text: 'zeige Koordinaten',
                            callback: showCoordinates
                        }, {
                            text: 'Karte hier zentrieren',
                            callback: centerMap
                        }]
                    });
                }
                
                function newMeasurement(e){
                //do something with e AND ID
                }
                

                我想過這樣的事情:

                //function x(){...
                callback: newMeasurement(e,id)
                //...}
                
                function newMeasurement(e,id){
                  console.log(id);
                }
                

                ...但這不起作用:(

                ...but that's not working :(

                感謝大家的幫助!

                推薦答案

                你需要為你想要的值創建一個閉包.

                You need to create a closure over the value you want.

                首先,閱讀 ?JS 閉包如何工作?? 問題.

                然后,閱讀 MDN 閉包參考.然后,this question about how to create different Leaflet event handlers pass每個處理函數的值不同

                首先閱讀這些內容.嘗試理解這個概念.我是認真的.如果你一味地復制粘貼代碼,那么stackoverflow的神會殺了一只小貓.

                Read those first. Try to understand the concept. I mean it. If you blindly copy-paste code, then the gods of stackoverflow will kill a kitten.

                現在,你想要一個事件處理函數,它只接收一個參數,比如

                Now, you want to have an event handler function, which will receive just one parameter, like

                function newMeasurement(ev){
                    // do something with 'ev' AND 'id'
                }
                

                那個函數需要接收一個參數,并且需要在某處有一個id變量.好的,那么,讓我們創建一個返回函數的函數:

                That function needs to receive one parameter, and needs to have an id variable somewhere. OK then, let's create a function that returns a function:

                function getMeasurementHandler(id) {
                    return function(ev) {
                        doSomething(ev, id);
                    }
                }
                

                這樣,如果你運行例如:

                That way, if you run e.g.:

                var handlerForId1234 = getMeasurementHandler(1234);
                

                這或多或少等同于

                var handlerForId1234 = function(ev) { doSomething(ev, 1234); }
                

                讓我們把它們放在一起:

                Let's put it all together:

                for (var id=0; id<4; id++) {
                    arrMap[id] = new L.map('map'+id, {
                        contextmenuItems: [{
                            text: 'Somethingsomething',
                            callback: getEventHandlerForId(id)
                        }]
                    });
                }
                
                getCallbackFuncForId(id) {
                    return function(ev) {
                        console.log('Event ', ev, ' in ID ', id);
                    }
                }
                

                這篇關于Leaflet.contextmenu 回調的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 中的默認加載磁貼顏色?)
                Add external geojson to leaflet layer(將外部geojson添加到傳單層)
                Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側邊欄)
              • <small id='6oTcU'></small><noframes id='6oTcU'>

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

                    <tbody id='6oTcU'></tbody>
                      • <legend id='6oTcU'><style id='6oTcU'><dir id='6oTcU'><q id='6oTcU'></q></dir></style></legend>

                          <bdo id='6oTcU'></bdo><ul id='6oTcU'></ul>
                        • <tfoot id='6oTcU'></tfoot>
                          主站蜘蛛池模板: 日韩亚洲欧美一区 | 国产一区久久 | 国产成人精品午夜视频免费 | 一区二区三区四区国产 | 国产精品欧美一区二区三区不卡 | 亚洲免费在线视频 | 成人激情视频免费观看 | 欧美中文字幕在线观看 | 伊人网在线综合 | 中文视频在线 | 久久久久久久网 | 久久久中文| 久草在线 | 国产精品久久久久久久久久久久 | 一区二区三区四区免费视频 | 亚州精品天堂中文字幕 | 毛片免费视频 | 99re视频在线观看 | 波多野结衣电影一区 | 午夜精品一区 | 欧美亚洲网站 | 中文视频在线 | 欧美成人一区二免费视频软件 | 韩国av网站在线观看 | 亚洲国产精品一区二区第一页 | 亚洲电影一区二区三区 | 中文字幕av亚洲精品一部二部 | 久久国产精品无码网站 | 日韩欧美在线播放 | 久久国产成人精品国产成人亚洲 | 国产一级片av | 日韩欧美在线观看 | 亚洲精品成人网 | 久久一区二区精品 | 日韩毛片中文字幕 | 亚洲美女天堂网 | 极品在线| 国产亚洲一区二区三区在线观看 | 国产a级毛毛片 | 亚洲国产精品一区二区www | av无遮挡 |