[mapserver-users] Drawing a circle on a map

Sucharita Samuel iworktech.sucharita at gmail.com
Mon Apr 14 06:13:29 PDT 2008


 Hi Stephen,
                   Thanks for the hint. I was able to draw the circle, but
now my problem is that I want to move the centroid of the circle to the
point I click on the map.  I used the following code in the mapscript

            layerObj oTempLayer = map.getLayerByName("Circle");
            oTempLayer.open();
            oTempLayer.status = (int)mapscript.MS_ON;
            pointObj point = pixel2point(new pointObj(x, y, 0, 0));
            rectObj oRect = oTempLayer.getExtent();
            shapeObj oShp= oRect.toPolygon();
            pointObj oPoint = oShp.getCentroid();
            oPoint.setXY(point.x, point.y, 0);
            oShp.draw(map, oTempLayer, oImg);
            oImg = map.draw();
            oTempLayer.draw(map, oImg);

Can you please help me to rectify the above code?

Thanks,
Sucharita

On Sun, Apr 13, 2008 at 10:07 PM, Stephen Woodbridge <
woodbri at swoodbridge.com> wrote:

> Atul Dravid wrote:
>
> > Try asking for Sample Code to Stephen Woodbridge...
> >
> >
> > On 4/12/08, *Stephen Woodbridge* <woodbri at swoodbridge.com <mailto:
> > woodbri at swoodbridge.com>> wrote:
> >
> >    Sucharita Samuel wrote:
> >
> >        Hi all,
> >               I want to draw a circle of 5 km radius around the point I
> >        click on the map. I am using C# mapscript. Even if you can help
> >        me with the php code, it will be of great help.
> >
> >
> >    One way to do this is to create a template layer that defines a
> >    feature that is a circle with the STATUS OFF. Then in mapscript you
> >    can get the layer, set the status to ON and set the value of the
> >    origin of the feature and have mapserver draw it on top of your map.
> >
> >    -Steve W.
> >
> >    _______________________________________________
> >    mapserver-users mailing list
> >    mapserver-users at lists.osgeo.org <mailto:
> > mapserver-users at lists.osgeo.org>
> >    http://lists.osgeo.org/mailman/listinfo/mapserver-users
> >
> >
> >
> In mapscript you can change the status and the feature points to be what
> you want. Here is an example of the LAYER and a URL to display it. I will
> leave the mapscript as you homework assignment :) Actually, I don't have a
> simple example handy, nor the time to put one together at the moment. If you
> get stuck an a specific point ask the list, there are plently of people that
> can help with mapscript.
>
> -Steve
>
> MAP
>  EXTENT -180 -90 180 90
>  IMAGECOLOR 255 255 0
>  IMAGETYPE png
>  SIZE 400 200
>  UNITS DD
>
>  LAYER
>    NAME "circles"
>    TYPE circle
>    STATUS DEFAULT
>    FEATURE
>      # define circle as two points describing the opposite corners of
>      # of the bounding square about the circle
>      POINTS
>        -10.0 -10.0
>         10.0  10.0
>      END
>    END
>    CLASS
>      STYLE
>        OUTLINECOLOR 255 0 0
>      END
>    END
>  END
> END
>
>
> http://mt2.imaptools.com/cgi-bin/mapserv-5.1-dev?mode=map&map=/u/data/maps/circles.map
>
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20080414/07d4f349/attachment.htm>


More information about the MapServer-users mailing list