[OpenLayers-Users] Buffering and resizing a point

Mehmet Sirin m.sirin07 at googlemail.com
Thu Dec 17 05:15:07 EST 2009


hi, there you have the same problem: point-vectors stays as they are
-without stretching/resizing.

i just find the solution:

          function createCircle(lat, lon, radius){
           polygonLayer.removeFeatures(polygonLayer.features);
                var style = {
                    fillColor: '#ff0000',
                    strokeWidth: 1,
                    pointRadius: radius,  // in map coordinates

                };


               var point = new OpenLayers.Geometry.Point(lat, lon);
               var polygonFeature =
OpenLayers.Geometry.Polygon.createRegularPolygon(point,radius,30,0);
               var feature = new
OpenLayers.Feature.Vector(polygonFeature,null, style);


                polygonLayer.addFeatures([feature]);
                polygonLayer.setOpacity(0.5);


            }

2009/12/17 Ivan Grcic <igrcic at gmail.com>

> Hi, cant you make something like this:
> http://openlayers.org/dev/examples/styles-context.html
>
> On Thu, Dec 17, 2009 at 10:34 AM, Mehmet Sirin <m.sirin07 at googlemail.com>
> wrote:
> > hi,
> > since there isn't a buffer function integrated in openlayers i have to
> find
> > other ways to simulate buffering a point and displaying it:
> >
> >  function pointBuffer(lat, lon, radius,color){
> >            polygonLayer.removeFeatures(polygonLayer.features);
> >                 var style = {
> >                     fillColor: '#ff0000',
> >                     strokeWidth: 1,
> >                     pointRadius: radius,  // in pixels
> >
> >                 };
> >
> >
> >                 var point = new OpenLayers.Geometry.Point(lat, lon);
> >                 var feature = new OpenLayers.Feature.Vector(point,null,
> > style);
> >
> >                 polygonLayer.addFeatures([feature]);
> >                 polygonLayer.setOpacity(0.5);
> >
> >             }
> >
> >
> ---------------------------------------------------------------------------------------------------------------
> > ...
> >                                  var lonlat1=new
> > OpenLayers.LonLat(parseInt(radius),0);
> >                                  var lonlat2=new
> > OpenLayers.LonLat(parseInt(radius*2),0);
> >                                  var
> > pixel1=map.getLayerPxFromLonLat(lonlat1);
> >                                  var
> > pixel2=map.getLayerPxFromLonLat(lonlat2);
> >
> >
> >                                  var dist=
> > Math.abs(parseInt(pixel2.x)-parseInt(pixel1.x));
> >
> >
> >                                  createCircle(x,y,dist);
> >
> >
> --------------------------------------------------------------------------------------------------------------
> > It works fine, but now the problem:
> > When zooming in or out the point feature won't resize -that means it does
> > not changes. the pixel size/radius is the same in every zoom level.
> > for solving this, i thought of creating a linearring and then a polygon,
> of
> > which i know that will automatically resize with zooming.
> > i tried:
> > var linearRing = new OpenLayers.Geometry.LinearRing(point); //just one
> point
> > var polygonFeature = new OpenLayers.Feature.Vector(
> >  new OpenLayers.Geometry.Polygon([linearRing]),null, style);
> > but seems not to work..
> >
> >
> > anybody can help?
> >
> > regards
> > m.sirin
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users
> >
> >
>
>
>
> --
> Ivan Grcic
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091217/1f44ba91/attachment.html


More information about the Users mailing list