[OpenLayers-Users] Problem with repositioning XYZ layer by large distances (in IE?)

Rohan Parkes melanchthon76 at gmail.com
Sun Aug 28 23:23:02 EDT 2011


I have an application showing a map of Australia. The base layer is an XYZ
layer type using a third-party tile provider.

The application allows users to search for addresses. If they search for an
address that is fairly close to the starting postition, e.g. in the same
city, everything works as expected. However, if they search for an address
in another state, the baselayer goes almost completely off the map - you can
generally only see one tile in the upper LH corner.

This problem does not occur if they use a search mode that changes the zoom
level - only if the zoom level stays the same. And so far, I have only been
able to reproduce it in IE (I only have 8, but apparently the same problem
occurs in 9).

The issue with the zoom level seems to be that the Map class moveTo method
uses a different technique to reposition the map depending on whether the
action changes the zoom. If it does, it resets the map parameters -
specifically the layerContainerDiv.style.left and
layerContainerDiv.style.top are reset to 0px. If not, the viewport container
is repositioned via the centerLayerContainer method. This can alter the
viewport by large amounts.

If I search for an address in an outer suburb, it will generate offsets
like:

<div id="OpenLayers.Map_26_OpenLayers_Container" style="z-index: 749;
position: absolute; top: -40174px; left: -57732px;">
<div class="olLayerDiv" id="OpenLayers.Layer.XYZ_30" style="z-index: 100;
position: absolute; width: 100%; height: 100%;" dir="ltr"
_eventCacheID="OpenLayers.Layer.XYZ_30_eventCacheID_31">
<div style="z-index: 1; position: absolute; width: 256px; height: 256px;
overflow: hidden; top: 40298px; left: 58916px;">

which is OK.

However, recentering to another state produces much larger offsets:

<div id="OpenLayers.Map_26_OpenLayers_Container" style="z-index: 749;
position: absolute; top: 1332917px; left: 1342177.27px;">
<div class="olLayerDiv" id="OpenLayers.Layer.XYZ_30" style="z-index: 100;
position: absolute; width: 100%; height: 100%;" dir="ltr"
_eventCacheID="OpenLayers.Layer.XYZ_30_eventCacheID_31">
<div style="z-index: 1; position: absolute; width: 256px; height: 256px;
overflow: hidden; top: -1332886px; left: -1340930px;">

This results in a map in IE that is mostly offscreen, even though the
offsets in the tile divs seem to correct the offset in the Container div.

All I can think is that the positioning offsets in the second case are too
big in some way.

The map div is absolutely positioned, and in a jQuery tab, but no
repositioning or modification to the DOM takes place after the map is
loaded.

The layer code is pretty ordinary and the options don't seem to make any
difference:

var MapOptions = {
                    transitionEffect: "resize",
                    sphericalMercator: true,
                    buffer: 1,
                    wrapDateLine: true,
                    isBaseLayer: true,
                    minZoomLevel: <minZoom>,
                    maxZoomLevel: <maxZoom>,
                    numZoomLevels: arrResMap.length,
                    resolutions: arrResMap,
                    zoomOffset: <minZoom>,
                    units: 'm',
                    restrictedExtent: <restrictedExtent>,
                    maxExtent: new OpenLayers.Bounds(-20037508.34,
-20037508.34, 20037508.34, 20037508.34)
                };

(We have a local array of Spherical Mercator resolutions which is modified
to set the zoom range.)

I originally encountered this probelm using the OSM layer type, which of
course is an extension of the XYZ type.

Could anyone suggest the cause of this problem, and a solution?

Rohan Parkes
Melbourne
Australia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110829/f40ab269/attachment-0001.html


More information about the Users mailing list