Changes between Initial Version and Version 1 of PHPMapScriptAddPointScale


Ignore:
Timestamp:
Nov 20, 2009, 1:07:42 PM (14 years ago)
Author:
mdev
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PHPMapScriptAddPointScale

    v1 v1  
     1= Add a dynamic point to a layer with min/maxscaledenom =
     2
     3This shows you how to add a point like a city to your mapscript and to use min/max scaledenom to make the feature appear or disappear depending on your scale.
     4
     5{{{
     6<?php
     7
     8// example written by mdev and special thanks to ue and others on #mapserver that helped me resolve the issues
     9
     10
     11ini_set("display_errors", 1); // show errors for debug
     12
     13//dl('php_mapscript.so'); // if you need to load mapscript.so
     14
     15$map_path="../mapfiles/"; // set these to your path
     16$map = ms_newMapObj("../mapfiles/mapsimple.map"); // set to your mapfile
     17
     18// city layer
     19
     20$layer = ms_newLayerObj($map);
     21$layer->set("status", MS_ON);
     22$layer->set("type", MS_LAYER_POINT);
     23
     24$layer->set("minscaledenom", 70); // <------ Shows up if denom<71 and doesn't show if denom>=71
     25// you can change min to max or add another if you want for the other way around
     26
     27
     28// add new class to new layer
     29$class = ms_newClassObj($layer);
     30
     31$class->label->set("font", "arial-bold");
     32$class->label->color->setRGB(0, 222, 31);
     33$class->label->set("size", 10);
     34$class->label->set("type", MS_TRUETYPE);
     35$class->label->set("position", MS_CR);
     36$class->label->set("antialias", TRUE);
     37
     38
     39$style = ms_newStyleObj($class);
     40$style->color->setRGB(0, 0, 0);
     41$style->set("size", 8);
     42$style->set("symbol", 1);
     43$style->set("antialias", TRUE);
     44
     45$point = ms_newPointObj();
     46$point->setXY(-0.12, 51.50);
     47
     48$line = ms_newLineObj();
     49$line->add($point);
     50
     51$pointShape = ms_newShapeObj(MS_SHAPE_POINT);
     52$pointShape->add($line);
     53$pointShape->set("text", "London");
     54
     55$layer->addFeature($pointShape);
     56$image=$map->draw();
     57
     58
     59echo $map->scaledenom . '<br>'; // to check what your denom is
     60$map->drawLabelCache($image);
     61//$map->save("/tmp/test2.map"); // if you want to save mapfile to see your output
     62$image_url=$image->saveWebImage();
     63
     64
     65?>
     66
     67<HTML>
     68 <HEAD>
     69     <TITLE>Example 1: Displaying a map</TITLE>
     70 </HEAD>
     71 <BODY>
     72     <IMG SRC=<?php echo $image_url; ?> >
     73 </BODY>
     74</HTML>
     75
     76}}}