[mapserver-users] PHP/Mapscript Question

Stephen Woodbridge woodbri at swoodbridge.com
Thu Feb 14 22:27:33 EST 2002


Dan, et al,

In PHP/Mapscript 3.5, I want to add a marker to my map. With the CGI
interface I did something like: 
layer=marker&map_marker_feature=new&map_marker_feature_points={LON}+{LAT}&map_marker_feature_text={LABEL}

The map file section for is below.

I am correct that PHP/Mapscript does not have access to the FEATURE
Objects?

It seems that the way I should go about doing this using code based on
gmap75  I would be something like this in GMapDrawMap():

$img = $gpoMap->draw();

if ($HTTP_FORM_VARS["mx"])
{
  $dfmx   = doubleval($HTTP_FORM_VARS["mx"]);
  $dfmy   = doubleval($HTTP_FORM_VARS["my"]);
  $sfmtxt = $HTTP_FORM_VARS["mtxt"];

  $mlay   = $gpoMap->getlayerbyname("marker");
  $mlay->set("status", 1);

  $pnt    = ms_newPointObj();
  $pnt->setXY($dfmx, $dfmy);
  $pnt->draw($gpoMap, $mlay, $img, 0, $sftxt);
}

where layer marker in my map file would be defined like:

LAYER
  NAME marker
  TYPE POINT
  STATUS OFF
  CLASS
    NAME "User Marker"
    #TEXT "HERE"
    SYMBOL 'marker'
    COLOR 0 0 0
    LABEL
      TYPE TRUETYPE
      FONT arial-bold
      BUFFER 4
      SIZE 8
      POSITION AUTO
      COLOR 0 0 0
      BACKGROUNDCOLOR 255 255 204
    END
  END
  #FEATURE
  #  POINTS x y
  #END
END

Does this make sense? 
Is there a better way to do this?

Thanks,
  -Steve Woodbridge



More information about the mapserver-users mailing list