[Mapserver-users] GPS Coordinate Mapping - Wrong parameter count for settext()

Kasey Kirkham kasey at inexo.com
Fri Mar 26 19:21:51 EST 2004


Thanks to everyone who responded.  Homme Zwaagstra, I think your
solution will work nicely.  Now I'm working on a way to put a label on a
coordinate.  Here's what I've experimented with so far:

this is the source of the concept I'm working off of:
http://mapserver.gis.umn.edu/data2/wilma/mapserver-users/0001/msg00073.h
tml

The mapfile's layer entry:

  LAYER
    NAME "annotation_point"
    TYPE ANNOTATION
    STATUS ON
    LABELCACHE OFF 
  
    CLASS
      TEXT "?" 
      LABEL
        TYPE TRUETYPE
        FONT "symbol"
        SIZE small
      END
    END
  END

Here's how I'm trying to create the label on the php side:
 ...
$class_index = 0;
$layerObj_annotation = $map->getLayerByName('annotation_point');
$classObj_annotation = $layerObj_annotation->getClass($class_index);
$classObj_annotation->settext('test string');

$pointObj_coord1->draw($map, $layerObj_annotation, $image, $class_index,
''); 
 ...

But on execution, I get this error:
Warning: Wrong parameter count for settext() in
/home/mapserver.ontec.com/htdocs/map_test.php on line 83

In the class reference entry on ClassObj, I see only the one argument to
the settext method.  Of course if there is a better way to put labels on
a coordinate, that information is more than welcome.

Thanks,
Kasey

-----Original Message-----
From: mapserver-users-admin at lists.gis.umn.edu
[mailto:mapserver-users-admin at lists.gis.umn.edu] On Behalf Of Homme
Zwaagstra
Sent: Wednesday, March 24, 2004 2:22 AM
To: mapserver-users at lists.gis.umn.edu
Subject: Re: [Mapserver-users] GPS Coordinate Mapping


On Tue, Mar 23, 2004 at 05:29:17PM -0700, Kasey Kirkham wrote:
> Hi all,
> 
> I'm currently working on a GPS-oriented mapping application(with much 
> help from Chris over at DM) using mapserver and php/mapscript(4.0.1 
> and 1.177, respectively).  I need to be able to select coordinates out

> of a database and plot those coordinates over a map.  I can zoom to a 
> given extent through mapscript, but I'm at a loss as to how I can draw

> the points on the map.  I was referred to this document: 
> http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?VirtualSpatialData
> but I would like something that left connecting to the database and 
> preparing the points up to me.  It might also be necessary to create 
> layers with more complex shapes from a variable number of points.
> 
> So, what mapscript objects/methods can be used to create shape 
> files(or even the "shapes" themselves...) and to add them to the map 
> at execution time?  Of course, if I'm barking up the wrong tree 
> entirely, some redirection would be equally appreciated.
> 
> Thanks for you help,
> Kasey Kirkham
> 
> Inexo Solutions
> Phoenix, AZ

Other than creating a shapefile from a list of coordinates, the other
way of drawing a point on a map goes something like this (in PHP
mapscript):

<?php

$mapObj = ms_newMapObj('my_mapfile.map'); // instantiate the map object
$imageObj = $mapObj->draw();	// get an image representing the current
map

$pointObj = ms_newPointObj();	// get a point

// set the X and Y
$x = 400000.0;
$y = 150000.0;
$pointObj->setXY($x, $y); 

$layerObj = $mapObj->getLayerByName('my_point_layer'); // get the point
layer $class_index = 0;

$pointObj->draw($mapObj, $layerObj, $imageObj, $class_index, ''); //
draw the point

// get the url and print it out
$url = $imageObj->saveWebImage(); 
$imageObj->free();
print '<img src="'.$url.'" />';

?>

The creation of a point object and drawing should be repeated for each
point you need to draw. If you need labels, check out the POSTLABELCACHE
map attribute for layers and the mapObj drawLabelCache method.

Kind regards,

Homme Zwaagstra
_______________________________________________
Mapserver-users mailing list
Mapserver-users at lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users




More information about the mapserver-users mailing list