问题描述
作为标题,我有一个Leaflet(1.02版)地图,如果我在调用flyTo()动作后尝试放大,则该地图会中断.奇怪的是,如果我先进行缩放,则可以自由缩放,放大或缩小而不会破坏地图.平移也可以在flyTo()之后使用,但是除非我先调用zoomOut动作,否则放大仍会破坏地图.
As the title states, I have a Leaflet (version 1.02) map that breaks if I try to zoom in after calling a flyTo() action. Oddly, if I zoom out first, I can then zoom freely, in or out without the map breaking. Panning also works after the flyTo(), but zooming in will still break the map unless I first call a zoomOut action.
我没有达到最大缩放,这会在带有不同标记集的多张地图中发生.如果在flyTo()的zoomend处将Zoom设置为当前级别,则可以自由缩放,放大或缩小,但这会导致地图在flyTo()之后闪烁,并且非常不吸引人.
I am not at max zoom, and this happens in multiple maps with different sets of markers. If, at zoomend of the flyTo(), I setZoom at the current level, I can then zoom freely, in or out, but this causes the map to flicker after the flyTo() and is very unappealing.
对此有何想法?
提前谢谢!
推荐答案
我知道这时的帖子有些陈旧,但是如果有人遇到了他们在使用flyTo()函数使用传单并得到后续信息的情况缩放会产生奇怪的行为,那么问题可能出在您将参数传递给flyTo()的格式是什么.
I know this post is somewhat old at this point, but if anyone runs into a situation where they're using leaflet with the flyTo() function and getting subsequent weird behaviour with zooming then the issue may be what format you're passing your arguments to flyTo().
确保将经纬度转换为浮点,将缩放转换为整数.我遇到了这个问题,事实证明这是由于我的参数是以字符串形式传递的.使用字符串作为参数,flyTo()似乎可以很好地运行,但随后的缩放操作会异常地起作用.
Make sure the lat, lon are cast to float and zoom is cast to int. I ran into this issue and it turned out to be due to my parameters being passed in a strings. flyTo() seems to operate fine with strings as parameters but subsequent zoom operations act erratically.
这篇关于如果调用了放大功能,则传单地图在flyTo之后会中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!