2
votes

I have a flat game-world map that I've rastered with gdal2tiles.py (-p raster, obviously, as it has not geolocation info). Displaying it as a TMS layer works just fine.

I also have vector data I want to overlay. Through trial and error, I've found a configuration that almost works:

var scales = [0.692, 1.384, 2.768, 5.536, 11.072];
var options = {
    controls: [],
    maxExtent: mapBounds,
    scales: scales,
    units: 'm'
};

But I wonder why the values are so strange and if they are really correct. So basically the question is: What IS the actual scale of an OpenLayers map? How long is a linestring from 0,0 to 1,0 and how long to 0,1 ? What is the unit? Obviously it's not metres, and the documentation doesn't explain it anywhere, either.

In case it matters, my vector data is stored in a PostGIS database. It is generated, not from any real-world source.

1
what srid did you gave the postgis table? - RickyA
By API documentation and source code, there is no scales: array option for map. So probably scale and resolution are switched, as Cavila suggests. - user1702401

1 Answers

1
votes

Scales are the difference between ground units and screen units. You can see the current map scale denominator been displayed with the scale control or with a call to

var map = (OpenLayers.Map);
map.getScale();

If your vector data is in a Postgis database and stored as a geometry column then it should has a proper srid number. Your vector data must match your map srid code or be transformed into same srid. Check your map projection after it has finished rendering with a call like this:

var map = (OpenLayers.Map);
map.getProjection();

Your vector data srid must match the value reported above.

Do not you confusing those scale values with resolutions?