Get Radius in epsg 4326 with Openlayers 3

المشرف العام

Administrator
طاقم الإدارة
What is the best method for getting the radius of a circle in Openlayers 3 in epsg 4326 (geodesic)? I'm using this example for a base and trying to draw a circle while getting the radius, but using proj 4326 is proving difficult.Here's my code:

var pointerMoveHandler = function(evt) { if (evt.dragging) { return; }var tooltipCoord = evt.coordinate; if (sketch) { var output; var geom = (sketch.getGeometry()); if (geom instanceof ol.geom.Cirlce) { output = formatCircle(/** @type {ol.geom.Circle} */ (geom)); tooltipCoord = geom.getCenter().getRadius(); measureTooltipElement.innerHTML = output; measureTooltip.setPosition(tooltipCoord); }};var sourceProj = map.getView().getProjection(); var geom = /** @type {ol.geom.Circle} */(Circle.clone().transform( sourceProj, 'EPSG:4326')); var center= geom.getRadius; radius = Math.abs(wgs84Sphere.geodesicArea(center));var output; if (area > 10000) { output = (Math.round(area / 1000000 * 100) / 100) + ' ' + 'km2'; } else { output = (Math.round(area * 100) / 100) + ' ' + 'm2'; } return output;};radius = Math.abs(wgs84Sphere.geodesicArea(center)); isn't right, but I'm not sure what to put there....



أكثر...
 
أعلى