使用此处贴图的不同颜色到噪波标记
Different color to noise marker using here maps
本文关键字:颜色 更新时间:2023-09-26
在使用here-maps api进行聚类时,是否可以将不同的颜色应用于不同的噪声标记?
有一个主题选项可用,但这适用于所有标记。我想根据特定的条件将特定的颜色设置为特定的点。
使用自定义主题当然可以。H.clustering.DataPoint
对象的定义包括可以保持任意数据的data()
方法。
当你准备数据集时,你可以添加它,如图所示:
var dataPoints = [];
dataPoints.push(new H.clustering.DataPoint(lat, lng, null, {color :'red'}));
dataPoints.push(new H.clustering.DataPoint(lat, lng, null, {color :'green'}));
dataPoints.push(new H.clustering.DataPoint(lat, lng, null, {color :'blue'}));
// etc ...
如果你使用自定义主题,你可以从噪声点读取数据,并按照你认为合适的方式显示:
function colorfulClusteringTheme() {
var baseTheme = new H.clustering.DefaultTheme();
this.getClusterPresentation = function (cluster) {
var clusterIcon = baseTheme.getClusterPresentation(cluster).getIcon();
return new H.map.Marker(cluster.getPosition(), {
icon: clusterIcon,
min: cluster.getMinZoom(),
max: cluster.getMaxZoom()
});
};
this.getNoisePresentation = function (noisePoint) {
if (noisePoint.data.color === 'red'){
// add red noise point
return new H.map.Marker(noisePoint.getPosition(), { icon: redIcon });
}
if (noisePoint.data.color === 'green'){
// add red marker
return new H.map.Marker(noisePoint.getPosition(), { icon: greenIcon });
}
if (noisePoint.data.color === 'blue'){
// add blue noise point
return new H.map.Marker(noisePoint.getPosition(), { icon: blueIcon });
}
};
};
你可以用通常的方式将主题添加到地图上:
var clusteredDataProvider = new H.clustering.Provider(dataPoints, {
clusteringOptions: {
eps: 16,
minWeight: 5
},
theme: new colorfulClusteringTheme()
});
var clusteringLayer = new H.map.layer.ObjectLayer(clusteredDataProvider);
map.addLayer(clusteringLayer);
相关文章:
- 使用JS如何动态更改显示的html文件中的文本背景颜色
- 高亮显示时编辑文本大小和颜色
- 用与线条相同的颜色填充多折线图上的点
- 更改使用Chart.js创建的图表中的轴线颜色
- 如何使用jquery更改html中的背景颜色
- 动态更改高图中的系列颜色
- jsf中两个字符串的颜色代码差异
- 我们如何使用css或JavaScript在i/j上更改句点(点)的颜色
- d3.hexbin插件-动态定义颜色域以适应数据
- 我如何制作一个JS函数,它可以从相似的原始颜色双向更改为某个颜色
- 每个选择器的Jquery css颜色都在变化,但字体大小却没有变化
- Javascript对象类在单击时打开窗口进行颜色选择,并在更改时替换对象背景颜色
- jQuery动画-边框宽度和颜色
- JS幻灯片与CSS背景颜色变化
- 使用CSS/JavaScript更改剑道图工具提示文本颜色
- 使用Angular单击时更改特定图示符图标的颜色
- 如何使用D3生成特定范围内的随机颜色
- 比较javascript中的浮动并更改最高浮动的颜色
- 改变所有<td>为特定的桌子点击颜色
- 如何获得随机灯光颜色