1

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?

  • Actually, Google version V3.19 fails too. Only V3.18 works. – BigDutch Feb 19 '15 at 16:32
1

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

  • The panTo is a good solution as a workaround, in our case using the one degree (or even .5 degree) won't make much of a impact. I have also tried the Google map API, and it wouldn't fail there. – BigDutch Feb 21 '15 at 13:57
  • 1
    I open an issue with OpenLayers, and this is what they had to say: https://github.com/openlayers/openlayers/issues/1435 – BigDutch Feb 21 '15 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.