[Mapserver-users] Need Urgent Help on PHP/MapScript >> ms_newPointObj()

Ishrar Hussain ishrarh at yahoo.com
Tue Jul 20 14:10:25 EDT 2004


Dear Andy and Merlos,

Thank you both so very much, as both of your codes
helped me a lot.

I'm also looking forward to using LineObj of
PHP/MapScript. The sequence of code for drawing lines
on the fly seems a little different then drawing
points, as the points of a line need to be added one
by one.

Please help me in this regard, if possible.
Thanks once again, for everything.

Regards,
Ishrar



--- ANDY CANFIELD <andy_canfield at hotmail.com> wrote:
> 
> You can also make a copy of an existing layer on the
> fly with a new name 
> that way you don't have to build a whole new layer
> from scratch. That's how 
> I put geocoded points onto a map. I have a
> construction layer and I just 
> make copies of it as I need new layers that way the
> only thing I have to 
> change is the color of the symbol. I have the symbol
> of that layer as a star 
> so they geocode one textfile of addresses red and
> the next one blue etc so 
> they can look at the stars from different files at
> the same time. Each set 
> of different colored stars is simply a copy of that
> construction layer with 
> the symbol color changed.
> 
> It looks something like this psuedo code:
> 
> //draw the map with all your mapfile layers
> $img = $oMap->draw();
> 
> //get the dummy point layer
> $oConsLayer = $oMap->getLayerByName("Construction");
> 
> //make a copy of it
> $oConsLayer1 = ms_newLayerObj($oMap, $oConsLayer);
> 
> //give it a name
> $oConsLayer1->set("name", "Red Points");
> 
> //get the class object
> $oClass = $oConsLayer1->getClass(0);
> 
> //add the color to the map in case it's not there
> $colorId = $oMap->addColor(255,0,0);
> 
> //set your new color
> $oClass->set("color", $colorId);
> 
> //make a new point and give it coords
> $m_Point = ms_newPointObj();
> $m_Point->setXY($SomeX, $SomeY );
> 
> //draw the point
> $m_Point->draw($oMap, $oConsLayer1, $ img,  0,
> $StringToDisplay);
> 
> I may be forgetting some steps but that should be
> roughly what you need to 
> do to create a copy of an existing layer with a new
> color for the symbol.
> 
> 
> 
> 
> 
> >From: Merlos <merlos at tsc.uvigo.es>
> >Reply-To: merlos at tsc.uvigo.es
> >To: Ishrar Hussain <ishrarh at yahoo.com>
> >C$oConsLayer1C: mapserver-users at lists.gis.umn.edu
> >Subject: Re: [Mapserver-users] Need Urgent Help on
> PHP/MapScript  >> 
> >ms_newPointObj()
> >Date: Tue, 20 Jul 2004 01:34:28 +0200
> >
> >After making some tests, I think that if you want
> to create a new layer on
> >the fly you have to create using mapscript a new
> style and a new class as
> >well. On my tests, I removed the style of the
> INLINE layer and the result 
> >was
> >that it dissapeared on the map image, it seems that
> there is no default 
> >style
> >and class set.
> >
> >  I'm quite newbie, so maybe a phpmascript guru can
> corroborate my beliefs
> >
> >  Anywat, why don't you add an empty layer as I
> did?  That way you will 
> >save
> >coding time :-)
> >
> >Here you have the one I use:
> >
> >   LAYER
> >     NAME "INLINE"
> >     TYPE POINT
> >     STATUS ON
> >    CLASS
> >        NAME "0"
> >        STYLE
> >          COLOR 255 0 0 # red
> >          MAXSIZE 300 # default 50
> >          SYMBOL 'phone'
> >          SIZE 16
> >        END #style
> >    END #class
> >  END #layer
> >
> >
> >On Monday 19 July 2004 21:55, Ishrar Hussain wrote:
> > > Dear Merlos,
> > >
> > > Thank you very much for your reply.
> > >
> > > Seeing your code, the question I now have is
> that, if
> > > the "Inline" layer (as you've mentioned) is not
> > > present in my map file, and I create a point
> layer
> > > with ms_newLayerObj(), then do I need to draw()
> the
> > > layer before referring its instance while
> drawing the
> > > point?
> > >
> > > Looking forward to your reply.
> > > Thanks again.
> > >
> > > Regards,
> > > Ishrar
> > >
> > > --- Merlos <merlos at tsc.uvigo.es> wrote:
> > > > Try this. It works for me.
> > > >
> > > > <?php
> > > >
> > > > $my_map= ms_newMapObj('data/test2.map');
> > > >
> > > > $pt = ms_newPointObj();
> > > > $pt-> setXY(5,5);
> > > > $img = $my_map->draw();
> > > > //Inline is a POINT layer.
> > > > $layer = $my_map->getLayerByName('INLINE');
> > > > $pt->draw($my_map, $layer, $img, 0 ,'yuhuu');
> > > >
> > > >
> > > > $url = $img->saveWebImage();
> > > >
> > > > echo "<img src=\"$url\" alt=\"Yuhuu!\" />";
> > > >
> > > > ?>
> > > >
> > > > Regards. Merlos.
> > > >
> > > > On Monday 19 July 2004 17:52, Ishrar Hussain
> wrote:
> > > > > Please give me an example code showing how
> to use
> > > > > PointObj class, i.e. ms_newPointObj(), to
> > > >
> > > > dynamically
> > > >
> > > > > draw a point over an already created
> instance of
> > > > > MapObj, which have been instantiated with a
> static
> > > > > .map file.
> > > > >
> > > > > Using Maplab, I have created my web mapping
> > > > > application, which successfully published my
> shape
> > > > > files in 4 layers. The map is now static.
> And over
> > > > > this map, I need to draw with PHP/MapScript
> a new
> > > > > layer that will hold one dynamic point,
> whose
> > > > > coordinates I will be retrieving from a
> database
> > > >
> > > > using
> > > >
> > > > > PHP. (I am editing the drawmap.php file in
> the
> > > >
> > > > wrapper
> > > >
> > > > > folder for this.)
> > > > >
> > > > > Note that, I don't want to have this new
> layer
> > > > > definition in my map file, which will make
> the
> > > >
> > > > layer
> > > >
> > > > > static. I also cannot use any database
> connection
> > > >
> > > > in
> > > >
> > > > > the mapfile (postgis or postgre or mygis).
> Thus,
> > > > > PHP/MapScript's PointObj is my only choice.
> 
=== message truncated ===



		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail



More information about the mapserver-users mailing list