Problems with scaling and mouse events in Openlayers

I am having problems with the mouse being connected to the Openlayers map when the map is placed inside a fixed position DIV. The map works great when you are at the top of the browser window, but when you scroll the page, you can see that the zoom / click effects are shifted. Here you can check http://41.32.148.178:82/#!search=KFC%2F0%2F0%2F0%2F%2F to see what I mean.

It seems to the guys that he was facing the same problem, but did not receive any answers http://lists.osgeo.org/pipermail/openlayers-users/2010-July/018769.html

+1
source share
2 answers

This was a bug in the version of OpenLayers that I used (2.1), I upgraded to the latest version (2.11), and now everything works fine, thanks.

0
source

I think you need to adjust the position of the map based on the vertical and horizontal scollbar values.

For firefox, chrome, safari, opera use this code to get scroll values

window.pageXOffset window.pageYOffset 

whereas for this use

 document.body.scrollLeft document.body.scrollTop 

see examples here

http://www.howtocreate.co.uk/tutorials/javascript/browserwindow

http://www.w3schools.com/jsref/prop_win_pagexoffset.asp

+1
source

Source: https://habr.com/ru/post/1398987/


All Articles