[OpenLayers-Users] Having a non-visible Google Layer leads to 404's at map load

Jelmer Baas baas at speerit.nl
Thu Aug 9 00:15:43 PDT 2012


Hello,

I'm using OL 2.12 to add an optional Google Satellite baselayer:
map = new OpenLayers.Map({
div: 'map',
                projection: "EPSG:900913",
                controls: [...]
, layers: [
                    new OpenLayers.Layer.OSM("OpenStreetMap",
                        ["http://x/osm_tiles2/${z}/${x}/${y}.png"],
                        { transitionEffect: "resize", numZoomLevels: 24, opacity: 1 })
                    , new OpenLayers.Layer.Google("Google Satellite", {visibility: false, type: google.maps.MapTypeId.SATELLITE, numZoomLevels: 22, transitionEffect: "resize"})
]});

I had expected this to be enough to make the Google layer invisible, yet, at page load I get about 50 404 errors:
"NetworkError: 404 Not Found - http://khm1.googleapis.com/kh?v=115&hl=en-US&x=1023&y=1024&z=11&token=68404"
Later, the url is changed to:
http://khm1.googleapis.com/kh?v=115&hl=en-US&x=1057&y=671&z=11&token=113046 (i.e., the token changes)
and the map loads succelfully. Yet, at this point my Google layer is still supposed to be invisible. I only want it to load when I turn it on by setting map.setBaseLayer().

Oh, the Google API is loaded by:
<script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script>

Any idea what I'm doing wrong?

Thanks in advance, 
Jelmer Baas




More information about the Users mailing list