当前位置:网站首页>Openlayers 5.0 discrete aggregation points
Openlayers 5.0 discrete aggregation points
2022-04-23 19:09:00 【GIS roast lamb leg is delicious】
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";
/* Discrete aggregation point 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) {
// The feature size of the current aggregate dimension data source
var size = parseInt(feature.get('features').length);
// Definition of style
var style = styleCache[size];
// Create if the current style does not exist
// 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 = [
// Initialize style
new Style({
// Point 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 = [
// Initialize style
new Style({
// Point 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 style
text: new Text({
// Text content
text: size==1?"":size.toString(),
// fill
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 roast lamb leg is delicious]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231908120712.html
边栏推荐
- Regular expressions for judging positive integers
- Is it safe to open an account in Bohai futures.
- 简化路径(力扣71)
- Druid SQL和Security在美团点评的实践
- std::stoi stol stoul stoll stof stod
- One of the reasons why the WebView web page cannot be opened (and some WebView problem records encountered by myself)
- Transaction processing of SQL Server database
- C: generic reflection
- js 计算时间差
- 7、 DOM (Part 2) - chapter after class exercises and answers
猜你喜欢
Introduction to ROS learning notes (I)
Switching power supply design sharing and power supply design skills diagram
Esp32 (UART ecoh) - serial port echo worm learning (2)
简化路径(力扣71)
Partage de la conception de l'alimentation électrique de commutation et illustration des compétences en conception de l'alimentation électrique
WebView opens H5 video and displays gray background or black triangle button. Problem solved
MySQL学习第五弹——事务及其操作特性详解
浅谈c语言指针的强制转换
Oracle configuration st_ geometry
I just want to leave a note for myself
随机推荐
SSDB基础2
SQL server requires to query the information of all employees with surname 'Wang'
2022.04.23(LC_714_买卖股票的最佳时机含手续费)
How about CICC wealth? Is it safe to open an account up there
Fundamentals of machine learning theory -- some terms about machine learning
浅谈c语言指针的强制转换
【C语言进阶11——字符和字符串函数及其模拟实现(2))】
Redis common interview questions
c1000k TCP 连接上限测试1
高层次人才一站式服务平台开发 人才综合服务平台系统
SSDB foundation 2
Introduction to micro build low code zero Foundation (lesson 3)
Wechat video extraction and receiving file path
微搭低代码零基础入门课(第三课)
RPM package management
An 8266 crash
SQL常用的命令
The type initializer for ‘Gdip‘ threw an exception
C1000k TCP connection upper limit test
Feature selection feature_ selection--SelectKBest