[GIS] Google Hybrid Map tiles won’t load in OpenLayers when centered on certain position

google mapsjavascriptjqueryopenlayers-2

Since the Google Maps API update to V3.2 (17 Feb 2015) our maps have not been loading to their initial state, centered over the Gulf of Mexico.

When the center location is: center: new OpenLayers.LonLat(-90, 25) it doesn't render, but OpenLayers.LonLat(-91, 25) works fine. Any 90 lat or 0 lon fails.

Can anyone explain why the following code does/does not work?

var map;

$(document).ready(function () {
    map = new OpenLayers.Map('olmap', {
        projection: 'EPSG:3857',
        layers: [
        new OpenLayers.Layer.Google(
            "Google Hybrid", {
            type: google.maps.MapTypeId.HYBRID,
            numZoomLevels: 20
        })],
        center: new OpenLayers.LonLat(-90, 25) //change to -91 and it works.
            .transform('EPSG:4326', 'EPSG:3857'),
        zoom: 4
    });
});

See jsFiddle for your experimenting pleasure.

If this is a bug, who do I report it to, Google or OpenLayers?

Best Answer

I haven't found out yet why exactly this does not work. but if you are interested in a "quick and dirty" workaround until you have found the error you could use this:

map.setCenter(new OpenLayers.LonLat(-91, 25).transform('EPSG:4326', 'EPSG:3857'),4); map.panTo(new OpenLayers.LonLat(-90, 25).transform('EPSG:4326', 'EPSG:3857'));

http://jsfiddle.net/expedio/bnnf6290/

I think the problem is OpenLayers related as the GoogleMaps-API can use this coordinate as initial center: http://jsfiddle.net/expedio/jg5opo5w/

what's strange: if i use a OpenLayers Google example with these coordinates outside jsfiddle it works at my site. perhaps you could try this file: https://gist.github.com/anonymous/90061cd545efc4e27acc