<!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编辑区域的更多相关文章

  1. openlayers显示区域

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  2. eclipse/myeclipse选中编辑区域文件,Package Explorer定位文件所在项目及目录

    eclipse/myeclipse选中编辑区域文件,Package Explorer定位文件所在项目及目录 1. 打开Package Explorer(若没有,可以按照如下路径点击: Window菜单 ...

  3. ECSHOP 模版文件里的编辑区域

    Ecshop 中的模板能够有可编辑区域,在模板中是通过 <!-- TemplateBeginEditable name="左边区域" --> <!-- Templ ...

  4. Selenium IDE编辑区域修改操作学习

    1.修改command.target.value,选择需要修改的步骤,然后点击下方,既可以直接进行修改. 2.添加新的操作步骤:直接在下方编辑区域的下方点击,然后输入或者选择操作类型,然后点击Targ ...

  5. word2010文档如何隐藏右侧灰色空白不可编辑区域

    word2010文档如何隐藏右侧灰色空白不可编辑区域, (word2007也是差不多的操作) 两种方法: 1.点击图中的“最终状态”按钮: 2.点击图中的”以嵌入方式显示所有修订“的按钮:

  6. openlayers画区域

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  7. Android获取状态栏高度、标题栏高度、编辑区域高度

    一.Activity界面的划分 简单说明一下(上图Activity采用默认Style,状态栏和标题栏都会显示):最大的草绿色区域是屏幕界面,红色次大区域我们称之为"应用程序界面区域" ...

  8. UEditor 之查询当前编辑区域的状态是源码模式还是可视化模式

    在使用百度的编辑器的时候,遇到了这样的一个问题: 解决方法是 使用了两个命令:

  9. vs2012修改代码编辑区域的背景色

随机推荐

  1. Why Oracle VIP can not be switched to original node ?

    Oracle RAC is an share everything database architecture. The article is how to check out why virtual ...

  2. NR / 5G - Uplink Carrier Waveform Generation

  3. docker:搭建ELK 开源日志分析系统

    ELK 是由三部分组成的一套日志分析系统, Elasticsearch: 基于json分析搜索引擎,Elasticsearch是个开源分布式搜索引擎,它的特点有:分布式,零配置,自动发现,索引自动分片 ...

  4. Angular解析json

    一. 解析本地Json数据并展示(待定) 1. 创建服务{ 创建一个接口对象用于接收Json数据 通过HttpClient获得本地Json文件 } 2. 组件中引入服务调用服务方法拿文件用subscr ...

  5. 在Unity中使用 luajit 64位加密

    参考:https://blog.csdn.net/sun19880421/article/details/68070696 https://blog.csdn.net/mydreamremindme/ ...

  6. 配置nginx代理服务器访问tomcat服务

    nginx原配置文件如下: #user nobody; worker_processes ; #error_log logs/error.log; #error_log logs/error.log ...

  7. 解决掉你心中 js function与Function的关系的疑问

    前言 在网上有很多关于js function 与 Function直接关系的文章. 但是我感觉过于抽象化了,那么如何是具体化的解释? 正文部分为个人理解部分,如有不对望指出. 正文 <scrip ...

  8. The finally block does not always execute in try finally

    A finally block does not always xecute. The code in the try block could go into an infinite loop, th ...

  9. MFC/QT 学习笔记(四)——MFC基于对话框学习控件(上)

    新建项目->MFC模板->MFC应用程序->应用程序类型:基于对话框->...OK 解决方案资源管理器->资源文件->xxx.rc->进入:资源视图-> ...

  10. ES集群调整搜索速度

    一.内存文件系统足够的缓存 Elasticsearch严重依赖于文件系统缓存,以加快搜索速度.通常,您应确保至少有一半的可用内存分配给文件系统缓存,以便Elasticsearch可以将索引的热区保留在 ...