Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I know how to make a predetermined Polygon in Openlayers (see below).

Please have a look at http://studio.netnrg.co.za/dev/rnd/blake.loizides/openlayers

      var feature2 = new OpenLayers.Feature.Vector(
      OpenLayers.Geometry.fromWKT("POLYGON((-120.828125 -50.3515625, -80.1875 -80.0078125, -40.40625 -20.4140625, -120.828125 -50.3515625))"
            )
        );
      vectors.addFeatures([feature2]);

I have made a Edit Circle (40 points in Openlayers) (My Client wanted to see a circle on the map for zones)

The problem I have is that I can only store the following details and not the 40 points or coordinates or Vertices to make a circle in Openlayers. I can only STORE 4 COORDINATES

In the Database I store the Bounds Top Bottom Left and Right (bottom: -29.054153382197, left: 23.782779686138, right: 23.79286499053, top: -29.044068077805) I will replace the coordinates with the ones in my database.

The Radius (525.627982303084)

And the Center Longitude and Latitude (lon=23.787822338334,lat=-29.049110730001)

Now I made some calculations below.

My Question is how do I now recreate a (circle) with the information i have above that is stored in my database?

I know how to get data from my database and display it on the map, What I don't know is how to make a circle if I cant store the 40 points and only have the Radius the Bounds and the Center Lon Lat to make a circle .

Please if anyone can help me I would be greatly appreciative.

I only want a Circle for the look and for no other reason.

My Calculations

Circle from Openlayers

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

I'm new to openlayers but this helped me you only need a center point (long lat) and a radius don't forget the function createGeodesicPolygon

Creating Vector features onload in Openlayers

there is a link to a demo

var origin = "new OpenLayers.Geometry.Point(Long Lat)"; 
//then set the radius here 
var polygon = createGeodesicPolygon(origin, RADIUS, 60, 0, map.getProjectionObject()) 

hope that helps

share|improve this answer
1  
Yes, and for origin use the center point of your bounds by doing a myBounds.getCenterLonLat(). example: var originLonLat = myBounds.getCenterLonLat(); var origin = new OpenLayers.Geometry.Point(originLonLat.lon originLonLat.lat); –  CaptDragon Apr 18 '12 at 17:30
1  
Here's a working example of it using your example bounds from database. jsfiddle.net/4S5Ke/5 –  CaptDragon Apr 18 '12 at 17:42
1  
And this one with your example radius: jsfiddle.net/4S5Ke/6 –  CaptDragon Apr 18 '12 at 17:45
    
Thanks Holly and Thanks CaptDragon that helped me alot . Thanks so much –  Blake Loizides Apr 18 '12 at 20:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.