[OpenLayers-Users] Buffering and resizing a point
Ivan Grcic
igrcic at gmail.com
Thu Dec 17 05:10:18 EST 2009
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
More information about the Users
mailing list