[OpenLayers-Users] TMS Layer origin and bounding box

Christopher Schmidt crschmidt at metacarta.com
Tue Apr 8 09:56:16 EDT 2008


On Tue, Apr 08, 2008 at 03:50:00PM +0200, Gérald Quintana wrote:
> The gdal2tiles.py tools generates a sample openlayers.html which works
> perfectly with the script http://www.openlayers.org/api/OpenLayers.js.
> As soon as I replace it by the 2.6rc1 release, I get an error
> "this.projection.getUnits is not a function" in the setMap function of
> the Layer class.

Oof. That's no good. 

> I think it comes from the way maxExtent and projection options are
> initialized in the example:
>        var options = {
>             controls: [],
>             maxExtent: new OpenLayers.Bounds(0, 0, 2770, 2270),
>             maxResolution: 16,
>             numZoomLevels: 5,
>             units: 'pixels',
>             projection: ""
>         };

Yeah, if you drop "projection":"" from that, it should work okay.

>         map = new OpenLayers.Map("map", options);
>         map.addControl(new OpenLayers.Control.PanZoomBar());
>         map.addControl(new OpenLayers.Control.MouseDefaults());
>         map.addControl(new OpenLayers.Control.KeyboardDefaults());
>         // OpenLayers 2.5 TMS driver
>         layer = new OpenLayers.Layer.TMS( "TMS",
>                 "", {layername: '.', serviceVersion: '.', type:'png'} );
>         map.addLayer(layer);
>         map.zoomTo(3);
> 
> Did someone used this gdal2tiles.py tool?
> How can I mix this TMS+strange SRS with a classical WMS layer+EPSG:4326?

Is your original image a worldwide map in EPSG:4326? If not, it's likely
that the answer is "You can't.", because OpenLayers doesn't support TMS
with different maxExtent and so on (though there is a Summer of Code
proposal to improve this.)

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list