Display Polyline length in feet using Leaflet.Draw toolbar

…衆ロ難τιáo~ 提交于 2019-12-12 12:57:58

问题


I am creating a map that the user will be able to draw lines on using the Leaflet.Draw toolbar. I would like the running distance of the line to be displayed in feet/miles instead of the default yards/miles. Looking at the project in GitHub, it seems to me the following code should do this:

 var drawControl = new L.Control.Draw({
            draw: {
                polyline: {
                    shapeOptions: {
                        color: 'red',
                    },
                    metric: false,
                    feet: true,
                }
            }            
        });

But the length is still displayed in yards. Any insight into why this is would be helpful.


回答1:


Which version of Leaflet.draw plugin are you using?

Note that:

  • Leaflet.draw version v0.2.4 / 0.2.4-dev (as used in the plugin GitHub demo) does not have the feet option yet.
  • Leaflet.draw version v0.3.0 / 0.3.0-dev (latest release for Leaflet 0.7) has the feet option.
  • Leaflet.draw from leaflet-master branch, for compatibility with Leaflet 1.0, is based on version 0.2.4 and does not have the feet option.


来源:https://stackoverflow.com/questions/38336028/display-polyline-length-in-feet-using-leaflet-draw-toolbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!