当前位置: 首页 > wzjs >正文

手机网站方案交换友链要注意什么

手机网站方案,交换友链要注意什么,旅游网站的设计与制作html,跳舞游戏做的广告视频网站注:当前使用的是 ol 5.3.0 版本,天地图使用的key请到天地图官网申请,并替换为自己的key 图形要素包括属性信息和几何信息,在实际应用中,不仅需要修改样式信息,也需要修改图形几何信息。在OpenLayers中&…

注:当前使用的是 ol 5.3.0 版本,天地图使用的key请到天地图官网申请,并替换为自己的key

图形要素包括属性信息和几何信息,在实际应用中,不仅需要修改样式信息,也需要修改图形几何信息。在OpenLayers中,一般采用鼠标交互方式修改图形坐标。在OpenLayers5中提供了ol.interaction.Modify交互式控件,可以结合选择要素控件ol.interaction.Select使用。

本节主要介绍加载图形交互编辑

1. 添加编辑几何图形

创建点、线、面几何图形并添加到地图中。

//绘制的几何图形要素
const pointFeature = new ol.Feature(new ol.geom.Point([11881771, 4588300]));
const lineFeature = new ol.Feature(new ol.geom.LineString([[11421771, 4288300], [12428781, 4288350]]));
const polygonFeature = new ol.Feature(new ol.geom.Polygon([[[11421771, 4228300], [11421771, 3588300], [11521771, 3588300], [11528771, 3688300], [12421771, 3988300]]]));//实例化一个矢量图层Vector作为绘制层
const source = new ol.source.Vector({features: [pointFeature, lineFeature, polygonFeature]
});
const vector = new ol.layer.Vector({source: source,style: new ol.style.Style({fill: new ol.style.Fill({color: 'rgba(255, 255, 255, 0.2)'}),stroke: new ol.style.Stroke({color: '#ff0000',width: 2}),image: new ol.style.Circle({radius: 7,fill: new ol.style.Fill({color: '#ff0000'})})})
});
//将绘制层添加到地图容器中
map.addLayer(vector);

2. 创建编辑控件

Modify控件中实现以下三个方法。

  • init:控件初始化
  • setEvents:设置事件,为当前选择的控件添加激活变更事件,在其事件处理函数中返回当前选择要素集的第一要素。
  • setActive:调用选择要素控件和交互式编辑控件setActive方法,控制控件是否激活。
//定义修改几何图形功能控件
const Modify = {init: function () {//初始化一个交互选择控件,并添加到地图容器中this.select = new ol.interaction.Select();map.addInteraction(this.select);//初始化一个交互编辑控件,并添加到地图容器中this.modify = new ol.interaction.Modify({//选中的要素features: this.select.getFeatures()});map.addInteraction(this.modify);//设置几何图形变更的处理this.setEvents();},setEvents: function () {//选中的要素const selectedFeatures = this.select.getFeatures();//添加选中要素变更事件this.select.on('change:active', function () {selectedFeatures.forEach(selectedFeatures.remove, selectedFeatures);});},setActive: function (active) {//激活选择要素控件this.select.setActive(active);//激活修改要素控件this.modify.setActive(active);}
};
//初始化几何图形修改控件
Modify.init();
//激活几何图形修改控件;
Modify.setActive(true);

3. 完整代码

其中libs文件夹下的包需要更换为自己下载的本地包或者引用在线资源。

<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>图形交互编辑</title><meta charset="utf-8" /><link href="../libs/css/ol.css" rel="stylesheet" type="text/css" /><script src="../libs/js/ol-5.3.3.js" type="text/javascript"></script><style>* {padding: 0;margin: 0;font-size: 14px;font-family: '微软雅黑';}html,body {width: 100%;height: 100%;}#map {position: absolute;width: 100%;height: 100%;}.ol-mouse-position {padding: 5px;top: 10px;height: 40px;line-height: 40px;background: #060505ba;text-align: center;color: #fff;border-radius: 5px;}</style>
</head><body><div id="map" title="地图显示"></div>
</body></html><script>//==============================================================================////============================天地图服务参数简单介绍==============================////================================vec:矢量图层==================================////================================img:影像图层==================================////================================cva:注记图层==================================////======================其中:_c表示经纬度投影,_w表示球面墨卡托投影================////==============================================================================////地图投影坐标系const projection = ol.proj.get('EPSG:3857');const map = new ol.Map({//地图容器div的IDtarget: 'map',view: new ol.View({//地图初始中心点// center: [114.2905, 30.5607],center: [11421771, 4288300],projection: "EPSG:3857",minZoom: 2,zoom: 4})});const gaodeLayer = new ol.layer.Tile({source: new ol.source.XYZ({title: "高德",url: "http://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}"})})map.addLayer(gaodeLayer)//绘制的几何图形要素const pointFeature = new ol.Feature(new ol.geom.Point([11881771, 4588300]));const lineFeature = new ol.Feature(new ol.geom.LineString([[11421771, 4288300], [12428781, 4288350]]));const polygonFeature = new ol.Feature(new ol.geom.Polygon([[[11421771, 4228300], [11421771, 3588300], [11521771, 3588300], [11528771, 3688300], [12421771, 3988300]]]));//实例化一个矢量图层Vector作为绘制层const source = new ol.source.Vector({features: [pointFeature, lineFeature, polygonFeature]});const vector = new ol.layer.Vector({source: source,style: new ol.style.Style({fill: new ol.style.Fill({color: 'rgba(255, 255, 255, 0.2)'}),stroke: new ol.style.Stroke({color: '#ff0000',width: 2}),image: new ol.style.Circle({radius: 7,fill: new ol.style.Fill({color: '#ff0000'})})})});//将绘制层添加到地图容器中map.addLayer(vector);//定义修改几何图形功能控件const Modify = {init: function () {//初始化一个交互选择控件,并添加到地图容器中this.select = new ol.interaction.Select();map.addInteraction(this.select);//初始化一个交互编辑控件,并添加到地图容器中this.modify = new ol.interaction.Modify({//选中的要素features: this.select.getFeatures()});map.addInteraction(this.modify);//设置几何图形变更的处理this.setEvents();},setEvents: function () {//选中的要素const selectedFeatures = this.select.getFeatures();//添加选中要素变更事件this.select.on('change:active', function () {selectedFeatures.forEach(selectedFeatures.remove, selectedFeatures);});},setActive: function (active) {//激活选择要素控件this.select.setActive(active);//激活修改要素控件this.modify.setActive(active);}};//初始化几何图形修改控件Modify.init();//激活几何图形修改控件;Modify.setActive(true);</script>

OpenLayers示例数据下载,请回复关键字:ol数据

全国信息化工程师-GIS 应用水平考试资料,请回复关键字:GIS考试

【GIS之路】 已经接入了智能助手,欢迎关注,欢迎提问。

欢迎访问我的博客网站-长谈GIShttp://shanhaitalk.com

都看到这了,不要忘记点赞、收藏 + 关注

本号不定时更新有关 GIS开发 相关内容,欢迎关注 !

http://www.dtcms.com/wzjs/76463.html

相关文章:

  • 申请域名后怎样建设网站锦州网站seo
  • 中小型网站建设讯息全网营销国际系统
  • wordpress接入小程序seo是搜索引擎营销
  • 中山做网站哪家便宜抖音的商业营销手段
  • 5 网站建设进度表苏州网站seo服务
  • 保定网站推广费用seo公司网站推广
  • 石家庄做网站怎么做公司网站
  • dede 网站打开慢佛山百度seo代理
  • 西安医院网站建设免费外链代发
  • 可以做签名链接的网站百度移动端优化
  • 苏州新港建设集团有限公司网站接app推广
  • 重庆市建筑工程信息官方网站交换链接适合哪些网站
  • 垫江网站建设djrckj广告开户
  • 做品牌推广网站需要多少钱站内seo内容优化包括
  • 一个刚起步的公司要如何管理山西seo谷歌关键词优化工具
  • 杭州知名网站制作公司网站搜索优化
  • 计算机应用软件开发流程图邵阳网站seo
  • 做物流哪个网站推广好3000行业关键词
  • 福州企业网站建站模板首页关键词怎么排名靠前
  • 什么是wap网站移动端seo关键词优化
  • 村建站全称2023近期舆情热点事件
  • 网站建设 点指成名重庆森林经典台词罐头
  • 菜鸟教程网站怎么做全网营销推广靠谱吗
  • 网站技术策划人员要求全媒体广告加盟
  • 农业技术网站建设原则淘宝运营培训班学费大概多少
  • 怎么做网赚网站南京seo优化培训
  • 做网络传销网站犯法吗seo建站收费地震
  • 网站建设青岛衡阳seo快速排名
  • 企业网站排名怎么做百度快照优化
  • 网站建设到维护seo网站编辑是做什么的