I want to draw a circle in openlayers with specific radius in km. with the center of specific geo point? I follow same as http://demo.gwt-openlayers.org/gwt_ol_showcase/GwtOpenLayersShowcase.html?example=Draw%20Regular%20Polygon%20Example but I want to draw automatically with predefined values.
解决方案
The following code will give you a circle in light blue centered at the center of the current map with a radius defined in meters. If you want it in feet, just replace:
var radius = (radius / ol.proj.METERS_PER_UNIT.m) * resolutionFactor;
with:
var radius = (radius / ol.proj.METERS_PER_UNIT.ft) * resolutionFactor;
Code:
var drawCircleInMeter = function(map, radius) {
var view = map.getView();
var projection = view.getProjection();
var resolutionAtEquator = view.getResolution();