0

I'm having a little trouble with what I thought would be quite easy. I'm trying to implement a map where you can zoom in and out with your mousewheel. This part works perfectly fine, but it's alway zooming that the top left corner stays at (0/0). I tried to give it the typical google maps zoom, but it didnt really work out.

I prepared a little jsFiddle for you to see what I'm talking about. As I said I tried to implement the centering part already in the centerOnMouse function, but I had no luck so far. maybee anyone can suggest how it can be altered to fit my needs. Thanks in advance.

4

1 回答 1

2

您只需将地图围绕视口中心对齐,取视口的一半宽度和一半高度,然后从该点进行缩放计算。您还可以使用鼠标在视口中的点来放大它。

于 2013-07-24T13:56:10.353 回答