[Mapserver-users] perl mapscript - progress...

Vinko Vrsalovic vinko at cprsig.cl
Mon Mar 3 21:29:18 EST 2003


On Mon, Mar 03, 2003 at 04:09:25PM -0800, Junkmail Box wrote:
> 
> Thanks for the help so far, especially Lowell. I can get perl-mapscript to
> draw a map that's already defined in a .map file, which is good progress.
> I wanted to look at the quakes demo to see what else I could learn, but
> I'm having a devil of a time trying to figure anything out.
> 
> Here's an attempt to draw a point on a map, that doesn't work. The
> underlying map draws A-OK, but the point isn't drawing.
> 
> 
> my $map = new mapscript::mapObj("arcata.map") or die "Cannot open map file\n";
> my $img = $map->prepareImage();
> my $layer = new mapscript::layerObj($map); $layer->{'name'} = 'points';
> $layer->{'type'} = $mapscript::MS_LAYER_POINT;
> 
> my $point = new mapscript::pointObj();
> # are these supposed to be lon/lat? arcata is 124W and 41N
> $point->{'x'} = -124; $point->{'y'} = 41;
> $point->draw($map,$layer,$img,undef,'HERE');
> $map->drawLabelCache($img);
> 
> $img->saveImage("example.png",$mapscript::MS_PNG,0,0,0);
> 
> 
> I gather from the quakes example that the pointObj's x and y are supposed
> to be lon/lat? The perl-mapscript doc doesn't specify.
> 
> Is there a tutorial on perl-mapscript, or is that reference the only
> document?

The defalt status for a layer is OFF :-)

$layer->{'status'} = $mapscript::MS_ON;

The point coordinates are supposed to be consistent to the rest of 
the data and the extent set in mapObj or the mapfile. 
If they are not you can project them. But according to the comment
above, you should be fine with those.

To debug this type of thing i use the mapObj->save() method, it's really
useful. Dunno if perl mapscript has it, though.

-- 
Vinko Vrsalovic <el[|- at -|]vinko.cl>
http://www.cprsig.cl



More information about the mapserver-users mailing list