本文介绍了在传单地图上添加jQuery标尺的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要沿着X,Y轴在传单地图上使用标尺,但是传单API不支持它,并且没有可用的插件.有一个jquery统治者可以满足我的需求.是否可以在传单地图上添加jquery标尺?

I need a ruler on leaflet map along X,Y axis but leaflet API does not support it and there is no plugin available. There is a jquery ruler that servers my needs. Is it possible to add jquery ruler on leaflet map ?

这里是示例: http://ruler.hilliuse.com/

标尺也必须调整为单张地图的缩放级别.请提出建议.

The ruler must adjust to the zoom level of leaflet map also. Please suggest.

推荐答案

还没有深入研究两者的代码,但这是需要权衡的:

Haven't taken a deep look into the code of either, but here's the trade off:

  • 传单的比例控制已被关联到传单缩放事件.应该可以复制x轴并将其作为y轴旋转90º.但是,请记住,小叶比例控制是用来测量球面(即地球)而不是xy平面上的距离的.

  • leaflet's scale-control will already be hooked up to leaflet zoom events. Should be possible to duplicate the x-axis and rotate it 90º as a y-axis. However, keep in mind that leaflet scale-control is meant to measure distance on a spherical surface (i.e. the earth), not a flat xy plane.

jquery统治者插件应该更容易破解,在内部,b/c不应用于测量球面距离.不过,您必须在缩放时更新其值.查看传单 zoomend 事件.像这样使用它:

the jquery ruler plugin should be easier to hack, internally, b/c it is not supposed to measure spherical distance. You'll have to update it's values on zoom, though. Check out the leaflet zoomend event. Use it like this:

map.on('zoomend', function(event){ updateRuler(...);});

map.on('zoomend', function(event){ updateRuler(...);});

传单事件文档

这篇关于在传单地图上添加jQuery标尺的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-11 07:19