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修改代码编辑区域的背景色
随机推荐
- Excel VBA: 自动生成巡检报表并通过邮件定时发送
目录 环境说明逻辑结构效果说明及截图①.安装SecureCRT②. 自动巡检脚本③. 数据检索并FTP传送④. 安装Excel 2013⑤. 安装Serv-U⑥. 自动生成图表并邮件发送 环境说明 系 ...
- 微信小程序开发技巧总结 (一)-- 数据传递和存储
结合自己在平时的开发中遇到的各种问题,和浏览各种问题的解决方案总结出一些自己在日常开发中常用的技巧和知点,希望各位不吝斧正. 1.短生命周期数据存储 以小程序启动到彻底关闭为周期的的数据建议存储在ap ...
- Git 分支设计规范
概述 这篇文章分享 Git 分支设计规范,目的是提供给研发人员做参考. 规范是死的,人是活的,希望自己定的规范,不要被打脸. 在说 Git 分支规范之前,先说下在系统开发过程中常用的环境. 简称 全称 ...
- Invoking Descriptors - Python 描述符的用法建议
描述符用法建议, 内置的 property 类创建的是'覆盖型'(date descriptor), 实现了 __set__ 和 __get__. 特性 property 的 __set__ 方法 默 ...
- Vue项目使用vant框架
近期在开发h5端项目,用到vant框架,vant是一款基于Vue的移动UI组件,看了vant的官方文档(https://youzan.github.io/vant/#/zh-CN/)感觉不错,功能比较 ...
- JAVA 对守护线程的理解
1.在start之前,setDaemon. 该现场就成为守护线程了. 2.守护现线程并不是主线程结束,子线程(守护线程)也跟着结束.而是守护线程在没有用户线程运行的情况伴随着JVM退出而结束. 示例代 ...
- [Pyhton]连接MSSQL实例并执行SQL语句
运行环境: 服务器端: MSSQL 2014 Server 2012 R2 程序端: Python 3.7.4 MacOS 10.14.6 CentOS Linux release 7.7.1908 ...
- 用Docker部署自己的JupyterHub
[话在前头] 用 Docker 部署 JupyterLab 感觉是部署 JupyterLab 最方便的方式了,官方提供了很多可选的镜像,也可以自己从 jupyter/base-notebook 中继续 ...
- App 抓包提示网络异常怎么破?
背景 当你测试App的时候,想要通过Fiddler/Charles等工具抓包看下https请求的数据情况,发现大部分的App都提示网络异常/无数据等等信息.以"贝壳找房"为例: F ...
- 掌握这四大MySQL知识点,吊打面试官
作为一名后端开发,MySQL的使用必不可少,合理的使用索引和索引调优是后端开发者必须掌握的技能之一. 在日常数据库的问题当中,不合理的使用索引占大部分. MySQL是大家工作上最常用的关系型数据库之一 ...