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

      1. <small id='93iGi'></small><noframes id='93iGi'>

        <legend id='93iGi'><style id='93iGi'><dir id='93iGi'><q id='93iGi'></q></dir></style></legend>

          <bdo id='93iGi'></bdo><ul id='93iGi'></ul>
      2. 如何在“popupopen"事件期间识别 Leaflet 的标记

        时间:2023-08-09
        <i id='GOTXb'><tr id='GOTXb'><dt id='GOTXb'><q id='GOTXb'><span id='GOTXb'><b id='GOTXb'><form id='GOTXb'><ins id='GOTXb'></ins><ul id='GOTXb'></ul><sub id='GOTXb'></sub></form><legend id='GOTXb'></legend><bdo id='GOTXb'><pre id='GOTXb'><center id='GOTXb'></center></pre></bdo></b><th id='GOTXb'></th></span></q></dt></tr></i><div id='GOTXb'><tfoot id='GOTXb'></tfoot><dl id='GOTXb'><fieldset id='GOTXb'></fieldset></dl></div>

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

        <tfoot id='GOTXb'></tfoot>

        <legend id='GOTXb'><style id='GOTXb'><dir id='GOTXb'><q id='GOTXb'></q></dir></style></legend>
            <tbody id='GOTXb'></tbody>
              • <bdo id='GOTXb'></bdo><ul id='GOTXb'></ul>

                  本文介绍了如何在“popupopen"事件期间识别 Leaflet 的标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  当一个标记被点击时,我需要执行一些代码,找到与被点击的标记对应的 id ,从后端 API 检索数据,然后将新检索到的数据添加到 将打开的弹出窗口的内容.

                  when a marker is clicked, I need to execute some code that finds the id corresponding to the marker being clicked , retrieves data from backend API, then adds the newly retrieved data to the content of the popup that will open.

                  能够监听标记上的点击事件的唯一方法是

                  The only way that is able to listen to a click event on the marker is

                  map.on('popupopen', function(e){
                      // How to retrieve marker?
                      // eg: Assign an id on creation, retrieve it now during popupopen
                  };)
                  

                  我怎样才能知道这是哪个标记?是否可以为每个标记添加 id 属性,然后在 popupopen 事件期间检索此 id?

                  How can I find out which marker this is? Is it possible to add an id attribute to each marker, then retrieve this id during the popupopen event?

                  推荐答案

                  事件对象包含一个popup"属性,该属性具有一个名为_source"的私有属性,该属性是弹出窗口绑定到的对象(即标记).由于 _source 应该是私有的,这似乎不是正确的方法,但我不知道该怎么做.

                  The event object contains a "popup" attribute that has a private attribute called "_source" which is the object that the popup is bound to (i.e. the marker). Since _source is supposed to be private this doesn't seem like the right way but I'm not sure how else to do it.

                  map.on('popupopen', function(e) {
                    var marker = e.popup._source;
                  });
                  

                  这篇关于如何在“popupopen"事件期间识别 Leaflet 的标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何将类添加到传单标记? 下一篇:Vuejs Leaflet:找不到地图容器

                  相关文章

                  最新文章

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

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

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

                    <tfoot id='j4uQF'></tfoot>

                  1. <legend id='j4uQF'><style id='j4uQF'><dir id='j4uQF'><q id='j4uQF'></q></dir></style></legend>