Google base maps misbehaving, blank tiles, not centered

classic Classic list List threaded Threaded
3 messages Options
crb
Reply | Threaded
Open this post in threaded view
|

Google base maps misbehaving, blank tiles, not centered

crb
I have an app that embeds two OL maps in different jQuery tabs on the same ASPX page.  I'm using OL v2.11.  When I use OpenLayers.Layer.Bing base layers (getting tiles direct, no Bing API) the maps render fine: it properly zooms to the predefined initial extent at the correct scale and renders all tiles.  But when I use OpenLayers.Layer.Google base layers (using API at http://maps.google.com/maps/api/js?v=3.5) then things don't work so well:  the first map renders with blank tiles and out-of-center (see image below) until I actually drag on it, which snaps it back into place.  



The second map is a map of search results, so it overlays markers on top of GMaps base layers, but this map never renders properly:  only the tile in the upper-left corner ever renders, and the rest of the map remains gray tiles (see image below).



The app uses the exact same class for the map that another app is using, and that application does not have the same problem even when using GoogleMaps. But the other app has a single map on the ASPX page and does not have nearly the same jQuery UI stuff going on.

There's a lot of code behind all this and I can certainly provide it if necessary, but the purpose of this initial post is to see if there are known issues rendering Google V3 base layers, particularly when the map is not the only thing in the browser viewport and shares it with other known JavaScript libraries, i.e. jQuery.
crb
Reply | Threaded
Open this post in threaded view
|

Re: Google base maps misbehaving, blank tiles, not centered

crb
The function repositionMapElements() (I used map.layers[0].repositionMapElements()) came to the rescue -- it was all I needed. It's a workaround and would be nice not to have to use it, but it works for now...
crb
Reply | Threaded
Open this post in threaded view
|

NOT RESOLVED: Google base maps misbehaving, blank tiles, not centered

crb
So there were two issues:
1. not all tiles loading properly, gray tiles getting loaded instead
2. the map not centered on the defined center point

Using repositionMapElements() fixed problem #1, but not #2.

What's happening with #2 is peculiar:  the map has the mouse position control so I can see from my mouse position that it is centered on the LonLat to which I did a setCenter().  But the tiles are offset so that they're actually displaying about 1 tile south and 1 tile east as the center point.  What's more, if I click and drag to pan the map ever so slightly, it snaps into the correct position.  Also, toggling the base map layer to a different layer also "snaps" the map back to the correct center point.

I tried doing this programmatically by doing:

        map.panTo(new OpenLayers.LonLat(map.getCenter().lon + 1, map.getCenter().lat + 1));
        map.panTo(new OpenLayers.LonLat(map.getCenter().lon - 1, map.getCenter().lat - 1));

and

        map.setBaseLayer(map.layers[1]);
        map.setBaseLayer(map.layers[0]);

upon initializing the map, but neither work. Though I'm not thrilled about using that as a solution anyway.

Thoughts?  Ideas?