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

    2. <small id='gfnPR'></small><noframes id='gfnPR'>

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

        Leaflet - 可拖动的标记和坐标以字段形式显示

        时间:2023-08-08
        <legend id='2iKv9'><style id='2iKv9'><dir id='2iKv9'><q id='2iKv9'></q></dir></style></legend>

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

          <bdo id='2iKv9'></bdo><ul id='2iKv9'></ul>
        • <small id='2iKv9'></small><noframes id='2iKv9'>

          <tfoot id='2iKv9'></tfoot>

                  本文介绍了Leaflet - 可拖动的标记和坐标以字段形式显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我必须做一个可拖动的标记,它的坐标应该显示在字段中.它将成为 PHP 中联系表单的一部分.我创建了一个可拖动的标记,请帮助我现在该怎么做.

                  I have to do a draggable marker and its coordinates should be displayed in fields. It will be a part of a contact form in PHP. I created a draggable marker, help me what to do now.

                  var marker = L.marker(new L.LatLng(53.471, 18.744), {
                  draggable: true
                  }).addTo(map);
                  

                  http://jsfiddle.net/xTh5U/

                  这是 Google Maps API 中的示例,我需要在 Leaflet 中使用相同的示例.

                  Here is example in Google Maps API, I need the same in Leaflet.

                  推荐答案

                  你应该使用L.Marker的dragend事件,所以你知道拖动已经结束,然后使用L的getLatLng方法获取标记的坐标.标记.获取这些内容后,您可以将它们分配给文本输入的值.

                  You should use the dragend event of L.Marker, so you known dragging has ended, then get the coordinates of the marker by using the getLatLng method of L.Marker. When you've fetched those you can assign them to the values of your text inputs.

                  marker.on('dragend', function (e) {
                      document.getElementById('latitude').value = marker.getLatLng().lat;
                      document.getElementById('longitude').value = marker.getLatLng().lng;
                  });
                  

                  Plunker 上的工作示例:http://plnkr.co/edit/iyMhaoAyllr2uNSOHhS9?p=preview

                  Working example on Plunker: http://plnkr.co/edit/iyMhaoAyllr2uNSOHhS9?p=preview

                  这篇关于Leaflet - 可拖动的标记和坐标以字段形式显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何将要在地图上显示的文本添加到传单中的 下一篇:使用传单 API 更新标记位置

                  相关文章

                  最新文章

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

                  <tfoot id='t8pa3'></tfoot>

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

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