sooo soweit bin ich
also kreiszeichnen geht
dummerweise der kreis ist in atlantik und ich bin in berlin
warum ist das so?
habe doch das selbe angegeben
Circle Test
p {
width: 500px;
}
var map, vectorLayer, polygonFeature, selectControl, selectedFeature;
function init(){
map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.OSM();
map.addLayer(layer);
map.addControl(new OpenLayers.Control.MousePosition());
map.addControl(new OpenLayers.Control.ScaleLine({bottomOutUnits: "km"}));
map.setCenter(new OpenLayers.LonLat(13.41,52.52).transform(
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
new OpenLayers.Projection("EPSG:900913") // to Spherical Mercator Projection map.Geometry.Polygon.createRegularPolygon = function(13.41,52.52,10000,20,1)
),15);
vectorLayer = new OpenLayers.Layer.Vector("Circle");
createCircle(13.41,52.52,111121.21,'#FF0000','#FF0000');
};
/////
var EARTH_RADIUS_KM = 6371.0088;
var EARTH_RADIUS_METERS = EARTH_RADIUS_KM * 1000.0;
/* degrees to radians */
function geoRadians(deg){
return deg * (Math.PI / 180.0);
};
/* radians to degrees */
function geoDegrees(rad){
return rad * (180.0 / Math.PI);
};
function createCircle(lat,lng,radiusKM,line,fill){
var rLat = geoRadians(lat); // radians
var rLon = geoRadians(lng); // radians
var d = radiusKM / EARTH_RADIUS_KM;
var pointList = [];
for (x = 0; x < 360; x += 5) {
var xrad = geoRadians(x);// radians
var tLat = Math.asin(Math.sin(rLat) * Math.cos(d) + Math.cos(rLat) * Math.sin(d) * Math.cos(xrad));
var tLon = rLon + Math.atan2(Math.sin(xrad) * Math.sin(d) * Math.cos(rLat), Math.cos(d)-Math.sin(rLat) * Math.sin(tLat));
Cx = geoDegrees(tLon);
Cy = geoDegrees(tLat);
var newPoint = new OpenLayers.Geometry.Point(Cx,Cy);
pointList.push(newPoint);
}
var myStyle = {strokeColor: line, fillColor: fill, fillOpacity: 0.4, strokeWidth: 1, pointRadius: 6, pointerEvents: "visiblePainted"};
pointList.push(pointList[0]);
var linearRing = new OpenLayers.Geometry.LinearRing(pointList);
polygonFeature = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Polygon([linearRing]),null,myStyle);
map.addLayer(vectorLayer);
vectorLayer.addFeatures([polygonFeature]);
};
</script>