openlayers:实现绘制交互来测量长度和面积
getLength()和getArea()函数计算几何体的球面长度和面积。 通过假设几何坐标之间的大圆段来计算Lectures。面积的计算就像多边形的边是大圆段一样。
请注意,geometry.getLength()和geometry.getArea()方法返回投影(平面)几何的测量值。 在某些情况下,这些可能与地面测量非常不同-例如在北方和南方纬度使用Web Mercator。 要获得更好的结果,请使用ol/sphere模块中的函数。
main.js
import Draw from 'ol/interaction/Draw.js';
import Map from 'ol/Map.js';
import Overlay from 'ol/Overlay.js';
import View from 'ol/View.js';
import {Circle as CircleStyle, Fill, Stroke, Style} from 'ol/style.js';
import {LineString, Polygon} from 'ol/geom.js';
import {OSM, Vector as VectorSource} from 'ol/source.js';
import {Tile as TileLayer, Vector as VectorLayer} from 'ol/layer.js';
import