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

Milo van der Linden milo at dogodigi.net
Thu Aug 9 00:59:07 PDT 2012


You need an extra optionset in your layer definition that holds visibility:

OpenLayers.Layer.Google("name",{youroptions},{visibility:false})

Verzonden vanaf mijn Samsung Galaxy S II
On Aug 9, 2012 9:21 AM, "Jelmer Baas" <baas at speerit.nl> wrote:

> 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
>
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120809/008f9fd9/attachment.html>


More information about the Users mailing list