我如何覆盖 osmdroid 中的默认捏合缩放?
我正在使用 Osmdroid 创建离线地图
现在,我想实现自己的捏合缩放离线地图功能
当用户使用捏合功能时,我想放大/缩小到特定的缩放级别,而不是增加/减少缩放级别 1
有没有办法做到这一点?我该怎么办?
PS:是的,有缩放控件,但我想让缩放功能更直观
谢谢
I m using Osmdroid to create an offline map
Now, i want to implement my own pinch to zoom functionality for offline maps
When user uses pinch, i would like to zoom in/ zoom out to only a particular zoom level and not increment/ decrement zoom level by 1
Is there a way to do it? how can i go about this ?
P.S : yes, there are zoom controls, but i would like to make zooming feature more intuitive
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我处理了类似的问题此处,并提供了自定义代码捏合功能。所以基本上,扩展我在答案中的内容,基本上就是这样做:
这只是将缩放级别增加 2 而不是 1 的示例。我也是凭记忆编写了上面的代码,所以我不是 100%当然,如果您调用
getController()
来获取当前和最大缩放级别,但我很确定就是这样。mOsmv
(以防万一您不明白)是 osmdroid 地图的一个实例。I dealt with a similar question here, and provided the code for custom functionality on pinch. So basically, expanding on what I had in the answer, just basically do:
That is just an example of increasing the zoom level by 2, instead of just 1. I also wrote the code above from memory, so I'm not 100% sure if you call
getController()
to get the current and maximum zoom level, but I'm pretty sure that's it.mOsmv
, just in case you don't get it, is an instance of the osmdroid map.我认为做到这一点的方法是扩展 MapView。
覆盖
setZoomLevel
看起来像是一种选择,但我认为它不会起作用。我相信代码需要以 this.setZoomLevel 风格编写,但它并没有一贯地这样做。我认为您应该能够覆盖
selectObject
,它看起来像是捏合触发调用的地方setZoomLevel
您将需要检查 源代码 查看如何制作必要的修改
I think the way to do this will be to extend MapView.
Overriding
setZoomLevel
looks like one option but I don't think it will work. As I belive the code needs to be writen in athis.setZoomLevel
style which it is not consistantly doing.I think you should be able to override
selectObject
which looks like the place where a pinch trigers a callsetZoomLevel
You will need to check the source code to see how to make the nessasary modifications