Get the radius size in meters from the drawn point

I draw points on the map using OpenLayers, as in this example: http://dev.openlayers.org/examples/draw-feature.html

Now I want to know which area (in meters) is covered by such a drawn dot. I know it depends on the zoom level. And this is also my plan: I want to draw my glasses in different sizes - depending on the zoom level. If the zoom level is maximum, the point should be large. If the zoom level is low, the point should be very small.

Does anyone have an idea how to calculate point size from pixel to meter?

+3
source share
3 answers

, . , , :
size_in_meters / map_resolution.

, :

styleMap = new OpenLayers.StyleMap({
    'default': new OpenLayers.Style({
        pointRadius: "${getSize}"
    },
    { context: {
        getSize: function(feature) {
            return size_in_meters / feature.layer.map.getResolution();
        }}  
    })
});
+6

:

ol.proj.METERS_PER_UNIT

/**
 * Meters per unit lookup table.
 * @const
 * @type {Object.<ol.proj.Units, number>}
 * @api stable
 */
ol.proj.METERS_PER_UNIT = {};
ol.proj.METERS_PER_UNIT[ol.proj.Units.DEGREES] =
    2 * Math.PI * ol.sphere.NORMAL.radius / 360;
ol.proj.METERS_PER_UNIT[ol.proj.Units.FEET] = 0.3048;
ol.proj.METERS_PER_UNIT[ol.proj.Units.METERS] = 1;

:

http://openlayers.org/en/v3.1.1/apidoc/proj.js.html

+1
source

All Articles