I am working a ol 2.13.1 & i have a strange issue. As base maps I have OSM & Google.

When I set as default Google it doesn't shows nothing. Only the OSM layer appears when selected.

BUT if i have the OSM as default then I switch between all base layers without issue.

var map = new OpenLayers.Map("map-id");
        var format = 'image/png';
        // pink tile avoidance
        OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;
        // make OL compute scale according to WMS spec
        OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;

        var googleMercator = new OpenLayers.Projection("EPSG:900913");
        var wgs84 = new OpenLayers.Projection("EPSG:4326");

        //base layer
        map = new OpenLayers.Map({
            div: "map",
            units: "m",
            projection: googleMercator,
            displayProjection: wgs84

        var mapBoxBackground = new OpenLayers.Layer.XYZ(" AWMC Background",["http://a.tiles.mapbox.com/v3/isawnyu.map-knmctlkh/${z}/${x}/${y}.png",
                attribution: "Tiles &copy; <a href='http://mapbox.com/' target='_blank'>MapBox</a> | " +
                "Data &copy; <a href='http://www.openstreetmap.org/' target='_blank'>OpenStreetMap</a> and contributors, CC-BY-SA |"+
                " Tiles and Data &copy; 2013 <a href='http://www.awmc.unc.edu' target='_blank'>AWMC</a>" +
                " <a href='http://creativecommons.org/licenses/by-nc/3.0/deed.en_US' target='_blank'>CC-BY-NC 3.0</a>",
                sphericalMercator: true,
                wrapDateLine: true,
                transitionEffect: "resize",
                buffer: 1,
                numZoomLevels: 13

        var google_var = new OpenLayers.Layer.Google(
                "Google LayerName",
                {type: google.maps.MapTypeId.BaseLayer}

         map.addControl(new OpenLayers.Control.LayerSwitcher());

         var google_hybrid = new OpenLayers.Layer.Google(
             "Google Hybrid",
             {type: google.maps.MapTypeId.HYBRID}


so this is doensn't work


but this works



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.