[OpenLayers-Users] Value of map.getExtent() is not precise?

Pedro Simonetti Garcia pedrosimonetti at gmail.com
Tue Apr 29 14:50:50 EDT 2008


Hi all,

I need a little help here. I'm developing a printing system, but I'm
getting some
problem with the extents.

I'm trying to print the map viewport, so I'm using the map.getExtent() and
map.getCurrentSize() values and passing it to the server, which calls the
mapserver and generates the image with the specified extent and size.

The problem is that the printed area is not exactly the same as showed at
the viewport. The output area is around 20% larger.

What I'm doing wrong? How can I precisely calculate the viewport extents?

The client code is something like this:

    var currentSize     = map.getCurrentSize();
    var viewportWidth   = currentSize.w;
    var viewportHeight  = currentSize.h;
    var extent          = map.getExtent();
    var sPrintExtent    = extent.toBBOX();

    var url = 'print.php?' +
              'size=custom' +
              '&width=' + viewportWidth +
              '&height=' + viewportHeight +
              '&extent=' + sPrintExtent;

    window.open(url);


To better understand what I'm talking about, take a look at this
screenshot of my viewport:
http://jproton.com.br/sandbox/viewport.JPG

And in the output image:
http://jproton.com.br/sandbox/print.jpg


my best regards,

Pedro Simonetti.



More information about the Users mailing list