openlayers / ol2

OpenLayers v2 - deprecated!
Other
1.47k stars 771 forks source link

Google Hybrid Map tiles won't load in OpenLayers when centered on certain position #1435

Open mickel1138 opened 9 years ago

mickel1138 commented 9 years ago

Since the Google Maps API update to V3.19 (also doesn't work in V3.20) 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 lon or 0 lat fails.

Example: 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 http://jsfiddle.net/mickel1138/cuz00fg9/ for your experimenting pleasure.

ahocevar commented 9 years ago

A latitude of -90 cannot be transformed to Web Mercator, because that lies in I finite space. For Web Mercator, you cannot use latitudes beyond 85 or 86 degrees reliably.

Closing because this is an application/configuration issue. If this configuration worked in the past, it worked by chance only.

ahocevar commented 9 years ago

Also note that OpenLayers.LonLat takes the longitude as first and the latitude as 2nd argument.

mickel1138 commented 9 years ago

I agree that a latitude of near 90 can be problematic, but the latitude in the example is 25, and the longitude is 90.

ahocevar commented 9 years ago

Reopening. You wrote latitude of 90, but meant longitude.

If you can provide a pull request with a fix, we'll gladly merge. But supporting the ever changing Google Maps API has been a pain so it's very unlikely that this will be fixed by one of the core devs.

mickel1138 commented 9 years ago

Sorry, yes, I mixed them up earlier (corrected now) although, the example was correct.

mickel1138 commented 9 years ago

I do believe this is a major bug, using 0 or 90 for either lon or lat causes the map not to render. Moving the map will make it render however.