mapObj.zoomRectangle from Java Mapscript.

Javier Caicedo jcaicedo at CTI.ESPOL.EDU.EC
Thu Dec 7 15:00:54 EST 2006


According to the Mapscript API mapObj.zoomRectangle first parameter must
be in  image coordinates, so you should set the last parameter of the
rectObj constructor to TRUE. Here goes an example from my current project:

  //vMap is an instance of mapObj
  rectObj rect = vMap.getExtent(); //map coordinates
  String [] box = getCurrentRequest().getParameter("box").split(" ");
  //box is something like this: 10 10 200 200
  //0,0 is at top left, so box defines top left and bottom right corners
  double mx = Double.parseDouble(box[0]);
  double my = Double.parseDouble(box[1]);
  double mxx = Double.parseDouble(box[2]);
  double mxy = Double.parseDouble(box[3]);

  //bunch of validation code ommitted

  rectObj rbox = new rectObj(mx,mxy,mxx,my,mapscriptConstants.MS_TRUE);
  //notice the switch of mxy and my
  //rectObj constructor requires you define bottom left and top right
  //corners. rbox is in image coordinates
  vMap.zoomRectangle(rbox,w,h,rect,null);

Hopefully this will help you out a little.

Regards,
Javier Caicedo Espinoza
CTI - ESPOL
Guayaquil, Ecuador



More information about the mapserver-users mailing list