[OpenLayers-Users] Change Layers, but Layer does not show until zoom out/in performed

Stephen Woodbridge woodbri at swoodbridge.com
Thu Jul 1 14:31:23 EDT 2010


OK, digging into this problem more I have found out why it is not 
displayed and how to hack it to cause it to display, but clearly I have 
no idea what I might be doing to cause this.

When I switch from Google to one of the EPSG:4326 layers there are bad 
values for:

map.layerContainerDiv.style.left
map.layerContainerDiv.style.top

When I catch the baseLayer changed event I added:

if (map.baseLayer.name != 'Google Map') {
     map.layerContainerDiv.style.left = "0px";
     map.layerContainerDiv.style.top  = "0px";
}

And this seems to fix the display problem. I'm sure this is not the 
intended way to fix this problem and I'm guessing that I am probably 
using part of the API in the wrong way. But I have not found who or what 
changes those values or why I'm getting numbers like -3e+10

Thanks,
   -Steve

Stephen Woodbridge wrote:
> Stephen Woodbridge wrote:
>> Hi Chris,
>>
>> Thank you for your feedback on changing layers. I got almost everything 
>> working. I think I ran into the remaining issue a long time ago, but I 
>> can not for the life of me find the old post or solution. And this might 
>> not be exactly the same problem.
>>
>> I have three base layers:
>>
>> 1. Tiger in EPSG:4326
>> 2. Google in EPSG:900913
>> 3. Streets in EPSG:4326
>>
>> and a couple of vector overlays that are always on.
>>
>> Everything works fine when I switch between any of the base layers 
>> EXCEPT when I change from Google to Streets.
> 
> It looks like changing from Google to Tiger also fails to draw. I 
> thought I had tried this before and it was working. But I guess it makes 
> some sense for consistency sake, but Tiger and Streets are virtually 
> identical definitions.
> 
> -Steve
> 
>> When I change from Google to Streets nothing is drawn in the view port. 
>> No mapserver image, no vector data, just the map controls. If I zoom in 
>> or out everything displays properly.
>>
>> There are no broken images, not javascript errors reported.
>> The NET panel shows that the image is requested and received.
>> In FF console:
>>
>> map.baseLayer.redraw()
>>
>> returns true but nothing is displayed.
>>
>> Here is the app currently under development:
>> http://imaptools.com:8080/routeloops/index4.php?zoom=11&lat=42.64057&lon=-71.36395&layers=B00TT&ll=-71.389033%2042.619456&len=10&rs=0.13877378737528812&av=1100%2C1200&u=E&cw=1#
>>
>> To reproduce the issue:
>>
>> 1. open the layerswitcher
>> 2. select Google Map (click through alerts)
>> 3. select Streets (click through alerts) - nothing displays
>> 4. zoom in or out - everything displays ok
>>
>> Any pointers would be appreciated.
>>
>> Thanks,
>>    -Steve
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list