[OpenLayers-Users] need help with projection issues

newbie shai_mus at hotmail.com
Tue May 5 11:11:12 EDT 2009


Dear All,
          If I need a circle based on a radius of 50m which function must I
use ? I just have a lat and long only. Thank you.

Christopher Schmidt-2 wrote:
> 
> On Fri, Jan 18, 2008 at 05:04:30PM +0100, O. Baum wrote:
>> Hi Thomas, all,
>> 
>> 2008/1/16, Thomas Wood <grand.edgemaster at gmail.com>:
>> > Yes, you will. displayProjection just tells controls to reproject
>> > before displaying or parsing coords they use.
>> >
>> > Reprojecting is fairly simple: [...]
>> 
>> ok, that works.
>> 
>> BUT if I want to draw a circle with the help of
>> OpenLayers.Geometry.Polygon.createRegularPolygon() it becomes an
>> ellipse. :(
>> I'm using this code:
>> 
>> ---8<---------------------------------
>> var circOrigin = new OpenLayers.Geometry.Point( 10.00, 49.50 );
>> var circStyle = OpenLayers.Util.extend( {},
>> OpenLayers.Feature.Vector.style["default"] );
>> var circleFeature = new OpenLayers.Feature.Vector(
>>  OpenLayers.Geometry.Polygon.createRegularPolygon( circOrigin, 0.001, 20,
>> 0 ),
>>  null,
>>  circStyle );
>> circleFeature.geometry.transform( new
>> OpenLayers.Projection("EPSG:4326"), new
>> OpenLayers.Projection("EPSG:900913") );
>> vectors.addFeatures( [circleFeature] );
>> --->8---------------------------------
>> 
>> 2 questions:
>> 
>> a) How and where can I apply the transformation so my circle is
>> 'really' (i.e. on the map) a circle?
>> b) In what units is the radius given? How can I calulate it from Meters?
> 
> Both of these questions can be answered by reprojecting your poitn
> *before* you create the polygon.
> 
> var circOrigin = new OpenLayers.Geometry.Point( 10.00, 49.50 );
> circOrigin.geometry.transform( new
> OpenLayers.Projection("EPSG:4326"), new
> OpenLayers.Projection("EPSG:900913") );
> 
> var circStyle = OpenLayers.Util.extend( {},
> OpenLayers.Feature.Vector.style["default"] );
> var circleFeature = new OpenLayers.Feature.Vector(
>  OpenLayers.Geometry.Polygon.createRegularPolygon( circOrigin, 100 /*
> meters */, 20, 0 ),
>  null,
>  circStyle );
> vectors.addFeatures( [circleFeature] );
> 
> Regards,
> -- 
> Christopher Schmidt
> MetaCarta
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> 

-- 
View this message in context: http://n2.nabble.com/need-help-with-projection-issues-tp1827236p2797350.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list