我在HighCharts中使用了一张地图,有时我只需要显示一段地图,而不是整个地图。我认为我可以通过放大到地图的一部分来手动完成这一任务,但理想情况下,我希望指定一个具有lat/lon坐标的边界框。我确信这一定是可能的,- in,API中提到了mapTransforms,但是我不知道如何使用它。https://api.highcharts.com/highmaps/chart.mapTransforms
在我的例子中,最好的方法是HighCharts只显示带有数据的地图部分,- there是API中的一个选项,不显示所有区域(https://api.highcharts.com/highmaps/series.map.allAreas),但这不是我想要的。这个选项不显示地图中没有数据的部分,我绝对不想这样做。
官方JSFiddle的一个例子如下:
// Prepare demo data
// Data is joined to map using value of 'hc-key' property by default.
// See API docs for 'joinBy' for more info on linking data and map.
var data = [
['eu', 0],
['oc', 1],
['af', 2],
['as', 3],
['na', 4],
['sa', 5]
];
// Create the chart
Highcharts.mapChart('container', {
chart: {
map: 'custom/world-continents'
},
title: {
text: 'Highmaps basic demo'
},
subtitle: {
text: 'Source map: <a href="http://code.highcharts.com/mapdata/custom/world-continents.js">World continents</a>'
},
mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},
colorAxis: {
min: 0
},
series: [{
data: data,
name: 'Random data',
states: {
hover: {
color: '#BADA55'
}
},
dataLabels: {
enabled: true,
format: '{point.name}'
}
}]
});
我会怎么做,使最初的地图加载,例如,主要是欧洲?
感谢任何能帮上忙的人!
发布于 2021-12-16 11:26:49
看看这些文档,您可以在其中找到示例:https://api.highcharts.com/class-reference/Highcharts.MapView#setView
不过,我认为对于您的情况,您应该使用zoomBy
特性:https://api.highcharts.com/class-reference/Highcharts.MapView#zoomBy
https://stackoverflow.com/questions/70377133
复制相似问题