Fw: Calculate extents based on points

Camden Daily cdaily at GMAIL.COM
Mon Jan 31 09:25:17 PST 2005


Maybe this would work:

Calculate half your extent
  $offset_x = ($max_x - $min_x) / 2;
  $offset_y = ($max_y - $min_y) / 2;

Find the midpoint
  $mid_x = $max_x - $offset_x;
  $mid_y = $max_y - $offset_y;
  $mid_point = ms_newpointObj();
  $mid_point->setXY($mid_x, mid_y);

Make your new extent
  $new_extent = array($longitude - $offset_x, $latitude - $offset_y,
$longitude + $offset_x, $latitude + $offset_y);

Zoom to the new point with the new extents
  $map->zoompoint(1, $mid_point, $map->width, $map->height, $new_extent);



More information about the MapServer-users mailing list