Problem using zoomPoint() map object method in Python Mapscript

Bill Hudspeth bhudspeth at EDAC.UNM.EDU
Thu Sep 2 11:37:41 EDT 2004


Hello,
Having trouble with the map object zoomPoint() function in python
mapscript. I set up the current view extents in utm coords, a point to
zoom to in pixel units, and then call zoomPoint() function. Nothing
changes on my view. I translated this code directly from a set of
pan/zoom functions that work in PHP. The logic is exactly the same, but
I don't get any resultant changes on screen. If anyone can spot what I
might be missing, I would much appreciate some feedback. Otherwise, a
possible problem with zoomPoint() function or my usage of it?

*********************************************************************************
self.nmMap = mapscript.mapObj(self.data)
ms_temp_dir = '/var/www/html/tmp'
ms_tmp_url = 'http://hyperion.unm.edu/tmp'

#build path to image
image_name='first.png'
self.image_path=os.path.join(ms_temp_dir, image_name)
#global image_url
self.image_url = os.path.join(ms_tmp_url, image_name)

#create default map extent object based upon mapfile
self.default_extent = self.nmMap.extent
self.img_width = self.nmMap.width
self.img_height = self.nmMap.height

pminx=450001
pminy=3567876
pmaxx=543234
pmaxy=4565342

#build and populate a rectangle object that represents the extent of the
previous map image
prevExtent=mapscript.rectObj(pminx, pminy, pmaxx, pmaxy)

#Define the point to pan to
zoomFactor = 1
#pan to the north
zoomToPt = mapscript.pointObj(self.img_width/2, 0)

#Set the extent of the current map to the an extent with the clicked
point at the center, zoomed by the above defined factor
self.nmMap.zoomPoint(zoomFactor,zoomToPt,self.img_width,
self.img_height, prevExtent, prevExtent)

#draw map
<input ID='mapimg' TYPE='image' SRC='self.image_url'>

*******************************************************************************************

Thanks, Bill



More information about the mapserver-users mailing list