代码拉取完成,页面将自动刷新
https://openlayers.org/en/latest/doc/tutorials/bundle.html
mkdir ol-demos && cd ol-demos
package.json
文件npm i -S ol
推荐使用淘宝源
npm i -D parcel-bundler
parcel-bundler 的功能与webpack类似,都是资源打包压缩、代码转换、热模块替换等等
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "parcel index.html",
"build": "parcel build --public-url . index.html"
},
npm start
启动开发服务器ctrl+c
结束开发服务器普通的点线面图形,通过设置type
为相应的要素类型,如Polygon
,即可由用户自行绘制(ol/interaction/Draw
)。
规则图形:https://openlayers.org/en/latest/examples/draw-shapes.html?q=freehand
使用Draw
的 geometryFunction
选项。
type
选项为Circle
,同时 geometryFunction = createRegularPolygon(4);
;type
选项同样为Circle
,但 geometryFunction = createBox();
;circle
的中心坐标及角度来关系绘制。
按住Shift
键自由绘制图形ProjectionLike字符串:类似"EPSG:XXXX"
ol.proj
模块
主要提供坐标系的转换等操作,默认是4326和3857的转换。
转换要素
feature.getGeometry().transform('EPSG:3857', 'EPSG:4326')
转换坐标
import {Projection,transform} from 'ol/proj'
//transform(coordinate, source, destination)
transform([x, y], new Projection("EPSG:4326"), new Projection("EPSG:3857"));
转换范围的投影
transformExtent(extent, source, destination)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。