Skip to content

Instantly share code, notes, and snippets.

@pp129
pp129 / alias.config.js
Created December 30, 2021 04:08
让webstorm识别webpack项目@别名
'use strict'
const path = require('path')
function resolve(dir) {
return path.join(__dirname, '.', dir)
}
module.exports = {
context : path.resolve(__dirname, './'),
resolve : {
@pp129
pp129 / openlayers 根据style设置显示级别并在字体加背景框.js
Created December 30, 2021 04:03
根据图层的属性字段设置图层显示级别
Iconstyle: function(feature, resolution) {
var style = new ol.style.Style({
fill : new ol.style.Fill({
color : 'rgba(241,242,236,0.8)',
}),
stroke : new ol.style.Stroke({
color : 'red',
width : 2
}),
image : new ol.style.Icon(({
@pp129
pp129 / OpenLayers 隐藏(hide)Feature.js
Created December 30, 2021 04:02
使用setStyle方法将Feature的样式设置为null
veclayer.getSource().getFeatures().forEach(function(item){
if (showFeature) {
item.setStyle(style);
} else {
item.setStyle(null);
}
})
@pp129
pp129 / openlayers 监听地图缩放.js
Last active January 10, 2022 01:51
只触发一次
map.once('postrender', function() {
map.once('moveend', function(evt) {
zoomend(evt)
})
})
function zoomend(evt) {
const zoom = evt.map.getView().getZoom()
}