[Mapserver-users] Mapscript: Display points on the fly

Bjoern Platzen bplatzen at sosnetz.de
Wed Jul 9 07:01:45 PDT 2003


Hi,

I'm trying to display a point at the last klickpoint in the map, but it 
doesn't appear on the map. I know that this has been discussed on the 
list a few times, but all the Examples I found were in Perl and I'm not 
really a Perl-programmer...

First of all, the mapObj (self.mymap) is defined and the image is 
prepared with

self.myimage=self.mymap.prepareImage()

My function to draw the point looks like that:

def _drawPoint(self, point):
        
    pLayer = self.mymap.getLayerByName('onthefly')
    pLayer.status = mapscript.MS_ON
    newPoint = mapscript.pointObj()
    newPoint.x, newPoint.x = point[0], point[1]
    newPoint.draw(self.mymap, pLayer, self.myimage, 0, 'Klick')
    self.layers.append('onthefly')

point is a tuple of the map-coordinates (eg. (2548085.3064984209, 
5674031.5200534584).

After _drawPoint, the function _drawLayers is called:

def _drawLayers(self):
    for l in self.layers:
        ll = self.mymap.getLayerByName(l)
        str(ll)
        ll.draw(self.mymap, self.myimage)

self.layers contains the layer-names

After that, the image is saved with

def makemap(self):
    self.mymap.drawLabelCache(self.myimage)
    out = 
self.myimage.saveImage(self.imgpath+self.outname,mapscript.MS_PNG,0,0,50)
        self.mapimg = self.imgpath+self.outname

In my mapfile, Ive got a layer 'onthefly':

LAYER
  NAME 'onthefly'
  TYPE POINT
  STATUS OFF
  CLASS
    Symbol 'phk'#Image-Symbol
  END
END

What am I missing? 

Bye, Bjoern
-- 
small office solutions
info at sosnetz.de  -  http://www.sosnetz.de




More information about the MapServer-users mailing list