惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 鼓舞飞扬

点表格,某一列出现报错。 qiankun使用关键代码 tinymce富文本编辑器使用 取消上次ajax 在vue项目中取消axios请求(单个和全局) JavaScript中的export、export default、exports和module.exports(export、export default、exports使用详细) 前端经典面试题 白屏优化 全网首发黑马程序员鸿蒙 HarmonyOS NEXT星河版零基础入门到实战,零基础也能快速入门鸿蒙开发教程 - 鼓舞飞扬 vue 图片资源应该如何存放并引入(public、assets)? 自定义树形模糊搜索 mapbox聚合使用自定义图标 mapbox gl 标注无法显示 报错 Error {message: ‘Unimplemented type: 4‘} mapbox加载图片类型图标 mapbox大数据展示 The engine “node“ is incompatible with this module.解决方法 配置镜像 【NPM报错】Node Sass does not yet support your current environment Turf.js简介
Mapbox添加多个不同的点图标
鼓舞飞扬 · 2024-07-30 · via 博客园 - 鼓舞飞扬
 1 // 添加多个点图
 2 function addMorePoint(data){
 3   if(mapboxMap.map.getSource('iconImageCircle')){
 4     mapboxMap.map.removeLayer('iconCircle')
 5     // mapboxMap.map.removeLayer('lineSources')
 6     mapboxMap.map.removeSource('iconImageCircle')
 7     mapboxMap.map.removeImage('first')
 8     mapboxMap.map.removeImage('second')
 9     mapboxMap.map.removeImage('third')
10   }
11   let features = []
12   for (let index = 0; index < data.length; index++){
13     let arrData =JSON.parse(data[index].points).features
14     arrData.forEach(item=>{
15       features.push(item)
16     })
17     // features.push({
18     //   "type": "Feature",
19     //   geometry:JSON.parse(data[index].points),
20     //   properties: {
21     //     ...data[index],
22     //     channelTypeA: data[index].channelType,
23     //     title:data[index].names
24     //   }
25     // })
26   }
27   for (const marker of features) {
28     var el1 = document.createElement('div');
29     new mapboxgl.Marker(el1)
30     .setLngLat(marker.geometry.coordinates)
31   }
32  
33   //加载img
34   mapboxMap.map.loadImage(require(`../assets/img/circle0.png`), function (error, image) {
35     if (error) throw error
36     mapboxMap.map.addImage('first', image, { sdf: false })
37   })
38   mapboxMap.map.loadImage(require(`../assets/img/circle1.png`), function (error, image) {
39     if (error) throw error
40     mapboxMap.map.addImage('second', image, { sdf: false })
41   })
42   mapboxMap.map.loadImage(require(`../assets/img/circle2.png`), function (error, image) {
43     if (error) throw error
44     mapboxMap.map.addImage('third', image, { sdf: false })
45   })
46   mapboxMap.map.loadImage(require(`../assets/img/point1.png`), function (error, image) {
47     if (error) throw error
48     mapboxMap.map.addImage('fourth', image, { sdf: false })
49   })
50   mapboxMap.map.loadImage(require(`../assets/img/point2.png`), function (error, image) {
51     if (error) throw error
52     mapboxMap.map.addImage('fifth', image, { sdf: false })
53   })
54   mapboxMap.map.addSource('iconImageCircle', {
55     type: 'geojson',
56     data: {
57       type: 'FeatureCollection',
58       features:features
59     }
60   });
61   mapboxMap.map.addLayer({
62     id: "iconCircle",
63     type: "symbol",
64     source: 'iconImageCircle', // 对应addSource第一个参数名字
65     layout: {
66       "icon-image": [
67         "case",
68         ['==', ['get', 'channelTypeA'], '51'],
69         'first',
70         ['==', ['get', 'channelTypeA'], '52'],
71         'second',
72         ['==', ['get', 'channelTypeA'], '53'],
73         'third',
74         ['==', ['get', 'channelTypeA'], '54'],
75         'fourth',
76         ['==', ['get', 'channelTypeA'], '55'],
77         'fifth',
78         "buming",
79       ], // 对应addImage()第一个参数名字
80       'text-field': ['get', 'title'],
81       "icon-allow-overlap": true,//如果设置为true,图标依旧显示,即使和已绘制的其他要素有碰撞
82       "icon-ignore-placement": true,//如果设置成true,即使其他要素有碰撞的情况下,依然可以显示
83       "text-allow-overlap": true,//是否允许文本重叠(可选,默认值为 false。当值为 true 时,文本即使和其他符号触碰也会显示)
84       "icon-size": 0.8,//图标的大小
85       "text-size": 12,
86     },
87   })
88 }