openlayers编辑区域
<!DOCTYPE html>
<html> <head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="lib/OpenLayers/ol.css" type="text/css"> <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="lib/OpenLayers/ol.js"></script>
<script src="olStyle/Light.js"></script>
<style>
html,
body {
width: 100%;
height: 100%;
margin: 0;
} .map {
width: 100%;
height: 100%;
background: #f6f6f4;
}
</style>
</head> <body>
<div id="map" class="map" data-id="11"></div>
<script type="text/javascript"> $(function () { InitMap(); AddPolygon(); //编辑
EditArea(); }) var map; var layer = new ol.layer.Vector({
source: new ol.source.Vector(),
style: new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(255, 0, 0, 0.5)'
}),
stroke: new ol.style.Stroke({
color: 'red',
width: 2
}),
image: new ol.style.Circle({
//半径大小
radius: 7,
//填充
fill: new ol.style.Fill({
//填充颜色
color: '#e81818'
})
})
})
}); //地图初始化
function InitMap() {
map = new ol.Map({
layers: [new ol.layer.Vector({
source: new ol.source.Vector()
}),
style: function (feature, resolution) {
switch (feature.get('layer')) {
case 'poi':
poiStyle.getText().setText(feature.get('name'));
return poiStyle;
case 'boundary': return boundaryStyle;
case 'lawn': return lawnStyle;
case 'road':
roadStyle.getText().setText(feature.get('name'));
return (resolution < 2) ? roadStyle : null;
case 'building':
return buildingStyle(feature, resolution);
case 'other':
otherStyle.getText().setText(feature.get('name'));
return otherStyle;
default: return null;
}
}
}), layer],
target: 'map',
view: new ol.View({
center: ol.proj.fromLonLat([120.277, 36.330]),
minZoom: 1,
zoom: 16
})
});
} /*显示并编辑区域**********************************************************************************/
function AddPolygon() {
layer.getSource().clear(); // var points = [[
// ol.proj.fromLonLat([120.27681827545163, 36.33236136226455]),
// ol.proj.fromLonLat([120.28038024902342, 36.33141061727086]),
// ol.proj.fromLonLat([120.27681827545163, 36.33001040806349]),
// ol.proj.fromLonLat([120.27681827545163, 36.33236136226455])
// ]] // var plygon = new ol.geom.Polygon(points)
// //多边形要素类
// var feature = new ol.Feature({
// geometry: plygon
// }); //var points = ol.proj.fromLonLat([120.27611017227173,36.331306898933306]);
var points = [13389075.33897296,4346304.97458048] var plygon = new ol.geom.Circle(points,294)
var feature = new ol.Feature({
geometry: plygon
}); layer.getSource().addFeature(feature); } function EditArea() { modify = new ol.interaction.Modify({
source: layer.getSource(),
});
//modify.setActive(true);
modify.on("modifyend", function () {
// 编辑结束时获取坐标点
// var features = layer.getSource().getFeatures(); // var geometry = features[0].getGeometry(); // var points;
// var lnglat = []; // points = geometry.getCoordinates()[0]; // for (var i = 0; i < points.length; i++) {
// lnglat.push(ol.proj.transform(points[i], 'EPSG:3857', 'EPSG:4326'));
// } // console.log(lnglat);
})
map.addInteraction(modify);
} </script>
</body> </html>
openlayers编辑区域的更多相关文章
- openlayers显示区域
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- eclipse/myeclipse选中编辑区域文件,Package Explorer定位文件所在项目及目录
eclipse/myeclipse选中编辑区域文件,Package Explorer定位文件所在项目及目录 1. 打开Package Explorer(若没有,可以按照如下路径点击: Window菜单 ...
- ECSHOP 模版文件里的编辑区域
Ecshop 中的模板能够有可编辑区域,在模板中是通过 <!-- TemplateBeginEditable name="左边区域" --> <!-- Templ ...
- Selenium IDE编辑区域修改操作学习
1.修改command.target.value,选择需要修改的步骤,然后点击下方,既可以直接进行修改. 2.添加新的操作步骤:直接在下方编辑区域的下方点击,然后输入或者选择操作类型,然后点击Targ ...
- word2010文档如何隐藏右侧灰色空白不可编辑区域
word2010文档如何隐藏右侧灰色空白不可编辑区域, (word2007也是差不多的操作) 两种方法: 1.点击图中的“最终状态”按钮: 2.点击图中的”以嵌入方式显示所有修订“的按钮:
- openlayers画区域
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- Android获取状态栏高度、标题栏高度、编辑区域高度
一.Activity界面的划分 简单说明一下(上图Activity采用默认Style,状态栏和标题栏都会显示):最大的草绿色区域是屏幕界面,红色次大区域我们称之为"应用程序界面区域" ...
- UEditor 之查询当前编辑区域的状态是源码模式还是可视化模式
在使用百度的编辑器的时候,遇到了这样的一个问题: 解决方法是 使用了两个命令:
- vs2012修改代码编辑区域的背景色
随机推荐
- mysql和 oracle 的区别
垂直拆分: 把一个数据库中不同业务单元的数据分到不同的数据库里面.水平拆分: 根据一定的规则把同一业务单元的数据拆分到多个数据库中. 读写分离 主:写 从:查 ==================== ...
- Go语言实现:【剑指offer】不用加减乘除做加法
该题目来源于牛客网<剑指offer>专题. 第一步:相加各位的值,不算进位,得到010,二进制每位相加就相当于各位做异或操作,101^111. 第二步:计算进位值,得到1010,相当于各位 ...
- 【机器学习】算法原理详细推导与实现(六):k-means算法
[机器学习]算法原理详细推导与实现(六):k-means算法 之前几个章节都是介绍有监督学习,这个章解介绍无监督学习,这是一个被称为k-means的聚类算法,也叫做k均值聚类算法. 聚类算法 在讲监督 ...
- 终于解决 k8s 集群中部署 nodelocaldns 的问题
自从开始在 kubernetes 集群中部署 nodelocaldns 以提高 dns 解析性能以来,一直被一个问题困扰,只要一部署 nodelocaldns ,在 coredns 中添加的 rewr ...
- centos 7 设置 本地更新源
#yum-config-manager --disable \*--屏弊所有更新源#mkdir /r7iso# cd /run/media/{用户名}/CentOS\ 7\ x86_64/ #cp - ...
- linux 手工释放内存 高内存 内存回收 方法思路
linux 跑的apache,apache工作模式有 Prefork.Worker和 Event 三种,分别是基于进程.线程.综合模式. 本文中使用的apache是 Event ...
- Linux 配置ip 子接口 多网卡绑定
linux系统配置ip地址,图形化界面略过,这里只介绍文本行.做以下设置注意是否有此权限 查看当前路由及网关信息: [root@localhost ~]# netstat -r Kernel IP r ...
- 蓝桥杯ALGO-1,区间k大数查询
#include<stdio.h> int devide(long a[], int low, int high) { long key = a[high]; while (low< ...
- VueJs一步步实现带感的帮助面板
环境 IDE: WebStorm 2019.1.4 系统: Mac OS X 10.15.4 VueJs: 2.6.11 Vue-cli: 4.2.2 前言 最近一直在忙毕设,前端终于还是对我这个 ...
- 记录 2020年2月26日 java的一次远程技术面试
1. 自我介绍 2.String 类型为什么是final类型?String 为啥不可变? String 类型是final类型原因: 1.不可变性支持线程安全(为了线程安全) 2.不可变性支持字符串常量 ...