OpenLayers 缩放样式类似于 GoogleMaps
在 GoogleMaps
中,当用户使用鼠标滚轮放大/缩小时,光标下的点保持不变(其坐标),但 OpenLayers
地图有不同的方法 - 当缩放地图中心时是恒定的。可以在 OpenLayers
地图中使用 GoogleMaps
缩放样式吗?
编辑: 实际上,我的 OpenLayers 中当前的行为是,当我放大光标下的某个位置时,它会将该位置移动到下一个缩放级别的地图中心。可能是与我的地图特定设置(如投影)相关的一些问题。
In GoogleMaps
when users zooms In/Out using mouse wheel the point under cursor stays the same (its coordinates), but OpenLayers
map has different approach - when zooming center of the map is constant. Can one use GoogleMaps
zoom style in OpenLayers
map?
EDIT:
Actually current behaviour in my OpenLayers
is that when I zoom in with some position under the cursor it moves that position to map center on the next zoom level. Probably it is some issue related to my map specific settings (like projection).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我猜您正在使用 OpenLayers.Control.MouseDefaults 控件进行导航。嗯,您不应该这样做,因为此控件已被 OpenLayers.Control.Navigation 替换,并且将在 OpenLayers 3.0 中弃用。
快速浏览一下 MouseDefaults 的源代码就会发现,它确实以光标位置为中心显示地图:
当光标停留在同一位置时,每次放大/缩小时地图都会以新位置为中心,这很令人困惑。
OpenLayers.Control.Navigation 使用与 Google 地图相同的方法。 OpenStreetMap 使用它,您可以在此处看到它的工作方式相同
I guess you are using OpenLayers.Control.MouseDefaults control for navigation. Well, you shouldn't, because this control is replaced with OpenLayers.Control.Navigation and will be deprecated in OpenLayers 3.0.
A quick look at source code for MouseDefaults shows that it definitely centers map on the cursor position:
While cursor stays at the same position the map will centered to new location every time you zoom in/out, which is confusing.
OpenLayers.Control.Navigation uses the same approach as Google Maps. OpenStreetMap uses it and you can see that it works the same way here
实际上,当查看 OpenLayers 的基本示例时,地图似乎会围绕鼠标指针,就像 Google 地图一样。或者我在你的问题中遗漏了一些细节?
Actually, when looking at the Basic Example at OpenLayers, it seems like the map zooms around the mouse pointer, just as Google Maps does. Or am I missing some detail in your question?