1、新建一个html页面,引入ol.js文件,然后在body中创建两个div标签和一个label标签;
2、代码实现
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script src="../lib/ol/ol.js"></script>
<script type="text/javascript">
window.onload = function () {
//初始化点要素
var pointFeature = new ol.Feature(new ol.geom.Point([0, 0]));
//初始化线要素
var lineFeature = new ol.Feature(new ol.geom.LineString([[-1e7, 1e6], [-1e6, 3e6]]));
//初始化多边形要素
var polygonFeature = new