当前位置:网站首页>openlayers 5.0 离散聚合点
openlayers 5.0 离散聚合点
2022-04-23 19:08:00 【Gis烤羊腿真好吃】
import {OSM, Vector as VectorSource} from 'ol/source.js';
import {Fill, RegularShape, Stroke, Style} from 'ol/style.js';
import Icon from 'ol/style/Icon.js'
import Vectorlayer from 'ol/layer/Vector.js'
import Feature from 'ol/Feature.js'
import Vector from "ol/source/Vector";
import Cluster from "ol/source/Cluster";
import Circle from "ol/style/Circle";
import Text from "ol/style/Text";
/*离散聚合点1*/
static createLayer(){
webgissource.clusterpointdate = new Vector();
webgissource.clusterSource = new Cluster({
distance:40,
source: webgissource.clusterpointdate
});
var styleCache = {};
webgissource.clusterVectorLayer = new Vectorlayer({
source: webgissource.clusterSource,
zIndex:999,
style: function (feature, resolution) {
//当前聚合标注数据源的要素大小
var size = parseInt(feature.get('features').length);
//定义样式
var style = styleCache[size];
//如果当前样式不存在则创建
// if(0<size && size<=5){
// var src="static/img/ld1.png"
// }else if(5<size && size<=10){
// var src="static/img/ld2.png"
// }else if(10<size && size<=15){
// var src="static/img/ld3.png"
// }else if(15<size && size<=20){
// var src="static/img/ld4.png"
// }else if(20<size ){
// var src="static/img/ld5.png"
// }
if(map.getView().getZoom()==17){
style = [
//初始化样式
new Style({
//点样式
fill: new Fill({
color: 'rgba(0,225,255,0.1)'
}),
stroke: new Stroke({
color: '#00e1ff',
width: 3
}),
image: new Circle({
radius: 6,
fill: new Fill({
color: '#4271ff'
})
}),
// image: new Circle({
// radius: 8,
// fill: new Fill({
// color: 'rgb(0,155,29)'
// })
// })
})
];
styleCache[size] = style;
}else{
//if (!style) {
style = [
//初始化样式
new Style({
//点样式
fill: new Fill({
color: 'rgba(0,225,255,0.1)'
}),
stroke: new Stroke({
color: '#00e1ff',
width: 3
}),
image: new Circle({
radius: size==1?6:14,
fill: new Fill({
color: '#4863ff'
})
}),
//文本样式
text: new Text({
//文本内容
text: size==1?"":size.toString(),
//填充
font: '14px',
fill: new Fill({
color: 'rgb(255,255,255)'
}),
offsetY: 0,
})
})
];
styleCache[size] = style;
//}
}
return style;
}
});
map.addLayer(webgissource.clusterVectorLayer)
}
static clusterVectorLayer(data){
var points=new Point([x,y]);
var iconFeature = new Feature({
geometry:points,
attributions:data
})
webgissource.clusterpointdate.addFeature(iconFeature)
}
版权声明
本文为[Gis烤羊腿真好吃]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_38190600/article/details/102488423
边栏推荐
- ESP32 LVGL8. 1 - roller rolling (roller 24)
- Esp32 (UART ecoh) - serial port echo worm learning (2)
- Introduction to ROS learning notes (I)
- Scrollto and scrollby
- Yyds dry goods inventory stringprep --- Internet string preparation
- Fundamentals of machine learning theory -- some terms about machine learning
- Wechat video extraction and receiving file path
- MySQL学习第五弹——事务及其操作特性详解
- Esp32 (UART event) - serial port event learning (1)
- Use of kotlin collaboration in the project
猜你喜欢
剑指 Offer II 116. 省份数量-空间复杂度O(n),时间复杂度O(n)
[popular science] CRC verification (I) what is CRC verification?
7、 DOM (Part 2) - chapter after class exercises and answers
Practice of Druid SQL and security in meituan review
该买什么设备,Keysight 给你挑好了
[记录]TypeError: this.getOptions is not a function
Raspberry pie 18b20 temperature
Esp01s with Arduino development environment
2022.04.23(LC_714_买卖股票的最佳时机含手续费)
Getting started with vcpkg
随机推荐
七、DOM(下) - 章节课后练习题及答案
[today in history] April 23: the first video uploaded on YouTube; Netease cloud music officially launched; The inventor of digital audio player was born
How about CICC wealth? Is it safe to open an account up there
Nacos as service registry
Tencent map and high logo removal method
Druid SQL和Security在美团点评的实践
从技术体系到商业洞察,中小研发团队架构实践之收尾篇
Introduction to ROS learning notes (II)
Usage of functions decode() and replace() in SQL
Introduction to micro build low code zero Foundation (lesson 3)
Use bitnami / PostgreSQL repmgr image to quickly set up PostgreSQL ha
Go language GUI framework Fyne Chinese garbled or not displayed
The fifth bullet of MySQL learning -- detailed explanation of transaction and its operation characteristics
Nacos cluster construction and MySQL persistence configuration
程序员如何快速开发高质量的代码?
The type initializer for ‘Gdip‘ threw an exception
One stop service platform for high-level talents and development of comprehensive service platform system for talents
Keysight has chosen what equipment to buy for you
How can programmers quickly develop high-quality code?
mysql_linux版本的下载及安装详解