1

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",
            "http://b.tiles.mapbox.com/v3/isawnyu.map-knmctlkh/${z}/${x}/${y}.png",
            "http://c.tiles.mapbox.com/v3/isawnyu.map-knmctlkh/${z}/${x}/${y}.png",
            "http://d.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

        map.addLayers([google_var,google_terrain,mapBoxBackground,google_hybrid,google_physical]);

but this works

map.addLayers([mapBoxBackground,google_var,google_terrain,google_hybrid,google_physical]);

Your Answer

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

Browse other questions tagged or ask your own question.