gpt4 book ai didi

javascript - 在高 map 中的纬度/经度 map 点上单击事件

转载 作者:行者123 更新时间:2023-11-30 15:02:21 25 4
gpt4 key购买 nike

我正在使用 highmaps 并被困在 lat/long map 上的 mappoint 上获取 click 事件。

是否有任何 API 引用可以在 map 点上应用 onclick 事件?

代码

// Initiate the chart
Highcharts.mapChart('container', {

title: {
text: 'Highmaps basic lat/lon demo'
},

mapNavigation: {
enabled: true
},

tooltip: {
headerFormat: '',
pointFormat: '<b>{point.name}</b><br>Lat: {point.lat}, Lon: {point.lon}'
},

series: [{
// Use the gb-all map with no data as a basemap
mapData: Highcharts.maps['countries/gb/gb-all'],
name: 'Basemap',
borderColor: '#A0A0A0',
nullColor: 'rgba(200, 200, 200, 0.3)',
showInLegend: false
}, {
name: 'Separators',
type: 'mapline',
data: Highcharts.geojson(Highcharts.maps['countries/gb/gb-all'], 'mapline'),
color: '#707070',
showInLegend: false,
enableMouseTracking: false
}, {
// Specify points using lat/lon
type: 'mappoint',
name: 'Cities',
color: Highcharts.getOptions().colors[1],
data: [{
name: 'London',
lat: 51.507222,
lon: -0.1275
}, {
name: 'Birmingham',
lat: 52.483056,
lon: -1.893611
}, {
name: 'Leeds',
lat: 53.799722,
lon: -1.549167
}, {
name: 'Glasgow',
lat: 55.858,
lon: -4.259
}, {
name: 'Sheffield',
lat: 53.383611,
lon: -1.466944
}, {
name: 'Liverpool',
lat: 53.4,
lon: -3
}, {
name: 'Bristol',
lat: 51.45,
lon: -2.583333
}, {
name: 'Belfast',
lat: 54.597,
lon: -5.93
}, {
name: 'Lerwick',
lat: 60.155,
lon: -1.145,
dataLabels: {
align: 'left',
x: 5,
verticalAlign: 'middle'
}
}]

fiddle - http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/maps/demo/mappoint-latlon/

以上是 highmaps 的示例,但我没有获得任何 API 引用来实现 lat/long mappoint 上的点击事件。

谢谢

最佳答案

查看引用 plotOptions.series.point.events.click

  plotOptions: {
series: {
point: {
events: {
click: function() {
var text = '<b>Clicked point</b><br>Series: ' + this.series.name +
'<br>Point: ' + this.name + ' (lat: ' + this.lat + ' lon:' + this.lon + ')',
chart = this.series.chart;
if (!chart.clickLabel) {
chart.clickLabel = chart.renderer.label(text, 0, 250)
.css({
width: '180px'
})
.add();
} else {
chart.clickLabel.attr({
text: text
});
}
}
}
}
}
},

Fiddle演示

关于javascript - 在高 map 中的纬度/经度 map 点上单击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46317603/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com