• <legend id='p0GwJ'><style id='p0GwJ'><dir id='p0GwJ'><q id='p0GwJ'></q></dir></style></legend>

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

      <tfoot id='p0GwJ'></tfoot>

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

        传单:不要在双击时触发点击事件功能

        时间:2023-08-09
        <tfoot id='FEh9t'></tfoot>

          <tbody id='FEh9t'></tbody>

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

              <bdo id='FEh9t'></bdo><ul id='FEh9t'></ul>
            • <small id='FEh9t'></small><noframes id='FEh9t'>

            • <i id='FEh9t'><tr id='FEh9t'><dt id='FEh9t'><q id='FEh9t'><span id='FEh9t'><b id='FEh9t'><form id='FEh9t'><ins id='FEh9t'></ins><ul id='FEh9t'></ul><sub id='FEh9t'></sub></form><legend id='FEh9t'></legend><bdo id='FEh9t'><pre id='FEh9t'><center id='FEh9t'></center></pre></bdo></b><th id='FEh9t'></th></span></q></dt></tr></i><div id='FEh9t'><tfoot id='FEh9t'></tfoot><dl id='FEh9t'><fieldset id='FEh9t'></fieldset></dl></div>
                1. 本文介绍了传单:不要在双击时触发点击事件功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个关于点击传单中地图的问题.如果我点击地图我想在那里设置一个标记,但如果我双击地图我只想放大而不设置标记.所以我有以下代码:

                  I have a question concerning clicks on a map in leaflet. If I click on the map I want to set a marker there, but if doubleclick on the map I just want to zoom in without setting a marker. So I have the follwing code:

                  var map = L.map(attrs.id, {
                              center: [scope.lat, scope.lng],
                              zoom: 14
                          });
                  var marker = L.marker([scope.lat, scope.lng],{draggable: true});
                  map.on('click', function(event){
                              marker.setLatLng(event.latlng);
                              marker.addTo(map);                
                          });
                  

                  现在的问题是,当我在地图上双击时,点击事件也会被触发,我想删除该行为.我怎样才能做到这一点?

                  The problem now is, when I doublclick on the map the click event is also fired and I would like to remove that behavior. How can I achieve that?

                  谢谢玛格达

                  推荐答案

                  所以,我找到了一种方法来做到这一点,我仍然不确定是否有更好的方法来做到这一点.

                  So, I found a way to do that, I am still not sure, if there is a better way to do it.

                  var map = L.map(attrs.id, {
                          center: [scope.lat, scope.lng],
                          zoom: 14
                      });
                  map.clicked = 0;                                                                      
                  L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
                          maxZoom: 18
                      }).addTo(map);
                  var marker = L.marker([scope.lat, scope.lng],{draggable: true});
                  map.on('click', function(event){
                      map.clicked = map.clicked + 1;
                      setTimeout(function(){
                          if(map.clicked == 1){
                              marker.setLatLng(event.latlng);
                              marker.addTo(map);                
                              map.clicked = 0;
                          }
                       }, 300);
                  });
                  map.on('dblclick', function(event){
                      map.clicked = 0;
                      map.zoomIn();
                  });
                  

                  这篇关于传单:不要在双击时触发点击事件功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:显示离线 OSM 映射文件.建议:一个带有 Js.library 的 下一篇:html2canvas 捕获除内部画布内容之外的所有内容

                  相关文章

                  最新文章

                  1. <small id='5XapY'></small><noframes id='5XapY'>

                    • <bdo id='5XapY'></bdo><ul id='5XapY'></ul>
                  2. <legend id='5XapY'><style id='5XapY'><dir id='5XapY'><q id='5XapY'></q></dir></style></legend>

                    1. <tfoot id='5XapY'></tfoot>

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