[OpenLayers-Dev] Issue with TMS - works for 2.7, but not 2.10

christopher.schmidt at nokia.com christopher.schmidt at nokia.com
Wed Mar 2 01:16:21 EST 2011


On Mar 2, 2011, at 5:23 AM, ext Phil Scadden wrote:

> I've been generating tiles with MapTiler that creates a stub for 
> openlayers to look at the file. Change this
> to my local Openlayers-2.10 and it stops working.
> 
> The issue occurs with initGriddedTiles and the call to addTile. This is 
> supposed to be implemented by subclass but not.

1. OpenLayers 2.10 (at least my copy) has an addTile method. On Layer.TMS.
   Does yours not?
2. Changing the script to 2.10/OpenLayers.js seems to work exactly the same
   way to me. The tile which is above new plymouth is 
   "TaranakiAtlas/Reservoir%20Potential-32/7/125/48.png" in both cases.

What symptom do you actually see?

If you publish your example on a webpage, it might help understand since
currently your tiles are all pink.

-- Chris

> 
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml>"
> <head>
> <title>Reservoir Potential-32.png</title>
> <meta http-equiv='imagetoolbar' content='no'/>
> <style type="text/css"> v\:* {behavior:url(#default#VML);}
>                 html, body { overflow: hidden; padding: 0; height: 
> 100%; width: 100%; font-family: 'Lucida 
> Grande',Geneva,Arial,Verdana,sans-serif; }
>                 body { margin: 10px; background: #fff; }
>                 h1 { margin: 0; padding: 6px; border:0; font-size: 20pt; }
>                 #header { height: 43px; padding: 0; background-color: 
> #eee; border: 1px solid #888; }
>                 #subheader { height: 12px; text-align: right; 
> font-size: 10px; color: #555;}
>                 #map { height: 95%; border: 1px solid #888; }
> </style>
> <script 
> src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=INSERT_YOUR_KEY_HERE' 
> type='text/javascript'></script>
> <script src="http://www.openlayers.org/api/2.7/OpenLayers.js" 
> type="text/javascript"></script>
> <script type="text/javascript">
>                 var map;
>                 var mapBounds = new OpenLayers.Bounds( 171.557011392, 
> -41.01960226, 175.486543045, -37.9967509295);
>                 var mapMinZoom = 6;
>                 var mapMaxZoom = 10;
> 
>                 // avoid pink tiles
>                 OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
>                 OpenLayers.Util.onImageLoadErrorColor = "transparent";
> 
>                 function init(){
>                 var options = {
>                     controls: [],
>                     projection: new OpenLayers.Projection("EPSG:900913"),
>                     displayProjection: new 
> OpenLayers.Projection("EPSG:4326"),
>                     units: "m",
>                     maxResolution: 156543.0339,
>                     maxExtent: new OpenLayers.Bounds(-20037508, 
> -20037508, 20037508, 20037508.34)
>                     };
>                 map = new OpenLayers.Map('map', options);
> 
>                 // create Google Mercator layers
>                 var gmap = new OpenLayers.Layer.Google("Google Streets",
>                     { sphericalMercator: true, numZoomLevels: 20} );
>                 var gsat = new OpenLayers.Layer.Google("Google Satellite",
>                     {type: G_SATELLITE_MAP, sphericalMercator: true, 
> numZoomLevels: 20} );
>                 var ghyb = new OpenLayers.Layer.Google("Google Hybrid",
>                     {type: G_HYBRID_MAP, sphericalMercator: true, 
> numZoomLevels: 20});
>                 var gter = new OpenLayers.Layer.Google("Google Terrain",
>                     {type: G_PHYSICAL_MAP, sphericalMercator: true, 
> numZoomLevels: 20 });
> 
>                 // create OSM/OAM layer
> 
>                 // create TMS Overlay layer
>                 var tmsoverlay = new OpenLayers.Layer.TMS( "TMS 
> Overlay", "data/TaranakiAtlas/Reservoir Potential-32/",
>                     {    //url: '', serviceVersion: '.', layername: '.',
>                         type: 'png', getURL: overlay_getTileURL, alpha: 
> true,
>                         isBaseLayer: false
>                     });
>                 if (OpenLayers.Util.alphaHack() == false) { 
> tmsoverlay.setOpacity(0.7); }
> 
>                 map.addLayers([gmap, gsat, ghyb, gter,
>                                tmsoverlay]);
> 
>                 var switcherControl = new 
> OpenLayers.Control.LayerSwitcher();
>                 map.addControl(switcherControl);
>                 switcherControl.maximizeControl();
> 
>                 map.zoomToExtent( 
> mapBounds.transform(map.displayProjection, map.projection ) );
> 
>                 map.addControl(new OpenLayers.Control.PanZoomBar());
>                 map.addControl(new OpenLayers.Control.MousePosition());
>                 map.addControl(new OpenLayers.Control.MouseDefaults());
>                 map.addControl(new OpenLayers.Control.KeyboardDefaults());
>             }
> 
> 
>             function overlay_getTileURL(bounds) {
>                 var res = this.map.getResolution();
>                 var x = Math.round((bounds.left - this.maxExtent.left) 
> / (res * this.tileSize.w));
>                 var y = Math.round((bounds.bottom - 
> this.tileOrigin.lat) / (res * this.tileSize.h));
>                 var z = this.map.getZoom();
>                 if (this.map.baseLayer.name == 'Virtual Earth Roads' || 
> this.map.baseLayer.name == 'Virtual Earth Aerial' || 
> this.map.baseLayer.name == 'Virtual Earth Hybrid') {
>                    z = z + 1;
>                 }
>                 if (mapBounds.intersectsBounds( bounds ) && z >= 
> mapMinZoom && z <= mapMaxZoom ) {
>                    //console.log( this.url + z + "/" + x + "/" + y + 
> "." + this.type);
>                    return this.url + z + "/" + x + "/" + y + "." + 
> this.type;
>                 } else {
>                    return "images/none.png";
>                 }
>             }
> 
> </script>
> </head>
> <body onload="init()">
> <div id="header"><h1>Reservoir Potential-32.png</h1></div>
> <div id="subheader">Generated by <a 
> href="http://www.maptiler.org/">MapTiler</a>/<a 
> href="http://www.klokan.cz/projects/gdal2tiles/">GDAL2Tiles</a>, 
> Copyright &copy; 2008 <a href="http://www.klokan.cz/">Klokan Petr 
> Pridal</a>, <a href="http://www.gdal.org/">GDAL</a> &amp; <a 
> href="http://www.osgeo.org/">OSGeo</a> <a 
> href="http://code.google.com/soc/">GSoC</a>
> <!-- PLEASE, LET THIS NOTE ABOUT AUTHOR AND PROJECT SOMEWHERE ON YOUR 
> WEBSITE, OR AT LEAST IN THE COMMENT IN HTML. THANK YOU -->
> </div>
> <div id="map"></div>
> <script type="text/javascript" >resize()</script>
> </body>
> </html>
> 
> -- 
> Phil Scadden, Senior Scientist GNS Science Ltd 764 Cumberland St, 
> Private Bag 1930, Dunedin, New Zealand Ph +64 3 4799663, fax +64 3 477 5232
> 
> 
> Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
> 
> _______________________________________________
> Dev mailing list
> Dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-dev



More information about the Dev mailing list