[Mapserver-users] why can't I draw a point on my map?
    Chris Black 
    cblack at CalAcademy.Org
       
    Fri Feb 14 12:49:16 PST 2003
    
    
  
Hello all.  I'm working on the early stages of a PHP MapServer 
application which will eventually query a database of museum specimen 
collection locations and throw dots up on a map.  For now, I'm building 
up an early prototype, just trying to draw a one-layer map and then put 
a dot on it at a particular location.  I don't see the dot or its label. 
 Am I missing a step?  I wasn't sure whether the x & y coordinates 
should be in pixels, meters, or decimal degrees -- so I tried it each 
way with no luck.  
Many thanks for any help you can give!
-- Chris
makedot.php:
------------------- cut here -------------------------------
<?php
dl('php_mapscript_36.dll');
$map_path="c:\\inetpub\\wwwroot\\mapserverapps\\izg\\";
   
$map_file="zoomableizg.map";
// Default values and configuration
$my_point = ms_newpointObj();
$map = ms_newMapObj($map_path.$map_file);
$image=$map->draw();
// let's try to show a place where there might be a crab
$crab_here = ms_newpointobj();
// I read this x & y values from a pointObj created by a mouse click,
// so I think they're correct
$crab_here->setXY(233, 340, 0);
// But just in case, I also tried each of the following, none of which 
worked:
// meters, got values from ArcView
//$crab_here->setXY(546180, 4184584, 0);
// decimal degrees
//$crab_here->setXY(37.8197, -122.4778, 0);
// and tried each of the above setting members directly instead of setXY 
method
//$crab_here->x = 233;
//$crab_here->y = 340;
//$crab_here->x = 546180;
//$crab_here->y = 4184584;
//$crab_here->x = 37.8197;
//$crab_here->y = -122.4778;
$crab_layer = ms_newlayerObj($map);
$crab_layer->set("status", MS_DEFAULT);
$crab_layer->status = MS_DEFAULT;
$dot_class = ms_newClassObj($crab_layer);
$dot_class->set("status", MS_ON);
$crab_here->draw($map, $crab_layer, $image, 1, "Cancer magister");
$image_url=$image->saveWebImage(MS_GIF,1,1,0);
?>
<HTML>
<HEAD>
<TITLE>Map</TITLE>
</HEAD>
<BODY>
<CENTER>
<img src="<?php echo $image_url?>" alt="bay map">
</CENTER>
</BODY>
</HMTL>
------------- cut here -----------------------
zoomableizg.map:
---------------------------- cut here -------------------------------
# Note: Comments in a map file are preceeded by the pound (#) sign.
# When MapServer encounters the pound sign, it will ignore the
# rest of the line.  Unfortunately, you can't comment a whole block
# of code or text in MapServer.  So, you're stuck with adding pound
# signs for every line you wish to comment out.
NAME CALCTYEX1
EXTENT 509945 4236585 629120 4135472
SIZE 709 606
UNITS METERS
SHAPEPATH "C:\inetpub\wwwroot\MapServerApps\IZG\data\"
WEB
    TEMPLATE ZoomableIZG.html
    IMAGEPATH "C:\inetpub\wwwroot\MapServerApps\data\tmp\"
    IMAGEURL "/MapServerApps/data/tmp/"
    LOG "c:\inetpub\wwwroot\mapserverapps\izg\mapserverlog.txt"
END # WEB
REFERENCE
    STATUS ON
    SIZE 144 123
    IMAGE "C:\inetpub\wwwroot\mapserverapps\izg\images\REFIMG.gif"
    EXTENT 509945 4236585 629120 4135472
    COLOR -1 -1 -1
    OUTLINECOLOR 255 0 0
END # REFERENCE
#LAYER
    #data "raster\relief.jpg"
    #NAME "bayraster"
    #STATUS DEFAULT
    #TYPE RASTER
#END # LAYER
LAYER # start of the "calcounties" layer object
  NAME "calcounties"
  DATA "vector\bayctys"
  STATUS DEFAULT
  TYPE POLYGON
  LABELITEM "Name"
  CLASS
    OUTLINECOLOR 204 0 0
  END # CLASS
END # LAYER
END # FILE
--------------- cut here ------------------------
    
    
More information about the MapServer-users
mailing list