const interpolateColor = this.createInterpolateColor(colorScheme);
const layer = new mtkWind.Layer(layerId, imageSource, {
styleSpec: {
'fill-color': [
'interpolate',
['step', 1],
['get', 'value'],
...interpolateColor,
],
opacity: config.opacity ?? 0.8,
},
renderFrom: mtkWind.RenderFrom.rg,
displayRange: config.displayRange,
renderType: mtkWind.RenderType.colorize,
picking: true,
});
this.map.addLayer(layer);
this.map.on('click', e => {
let pixel = this.map?.coordinateToContainerPoint(e.coordinate);
layer.layer.picker([pixel.x, pixel.y]).then((result: any) => {
// 使用新增的方法获取风力和风向
const windInfo = WeatherUtils.windUtil.uv2WindInfo(result[0], result[1]);
console.log('完整风信息:', windInfo);
})
});
const imageSource = new mtkWind.ImageSource(layerId, {
type: mtkWind.LayerSourceType.image,
coordinates: config.coordinates,
decodeType: mtkWind.DecodeType.imageWithExif,
wrapX: config.wrapX ?? true,
url: config.url,
});
实际只有红框处才能点出数值
