这是我的世界地图JavaScript。这个想法是为了使工具提示弹出窗口包含一个URL链接,允许用户单击它,并在另一个选项卡/窗口中打开URL。工具提示仅从指针移开,无法单击带有url的嵌入式标签。如何阻止工具提示从指针移开? (tooltipPosition:固定或指针未更改任何内容)
// Create map instance
var chart = am4core.create("chartdiv", am4maps.MapChart);
// Set map definition
chart.geodata = am4geodata_worldLow;
// Set projection
chart.projection = new am4maps.projections.Miller();
// Disable Zoom and Pan
chart.seriesContainer.draggable = false;
chart.seriesContainer.resizable = false;
chart.maxZoomLevel = 1;
// Series for gray background map
var worldSeries = chart.series.push(new am4maps.MapPolygonSeries());
worldSeries.exclude = ["AQ"];
worldSeries.useGeodata = true;
var polygonTemplate = worldSeries.mapPolygons.template;
polygonTemplate.fill = am4core.color("#ebebeb");
// Create map polygon series
var polygonSeries = chart.series.push(new am4maps.MapPolygonSeries());
// Make map load polygon (like country names) data from GeoJSON
polygonSeries.useGeodata = true;
// Configure series
var polygonTemplate = polygonSeries.mapPolygons.template;
polygonTemplate.tooltipHTML = "{name}<br/><a style=\"color:white; text-decoration: underline;\" href=\"{site}\" target=\"_blank\">{site}</a><br/>{email}<br/>{phone}";
polygonTemplate.adapter.add("tooltipHTML", function (html, ev) {
if (!ev.dataItem.dataContext.site) {
return "{name}";
}
return html;
})
polygonTemplate.fill = am4core.color("#6f52a8");
polygonSeries.tooltip.interactionsEnabled = true; // allow interaction
polygonSeries.tooltip.pointerOrientation = "vertical";
// Create hover state and set alternative fill color
var hs = polygonTemplate.states.create("hover");
hs.properties.fill = am4core.color("#442580");
// Include
polygonSeries.include = ["AD", "AR", "AM" , "AU", "AT", "BS" , "BB", "BZ", "BM", "BO", "BR",, "BG", "KH", "CM", "CA", "CL", "CN", "CO" , "HR", "DO", "AE", "EC", "EG", "DE", "GT", "HN", "HK", "IN", "ID", "IR", "IQ", "IL", "IT", "JP", "JO", "KW", "LB", "LY", "MK", "MX", "MM", "NL", "NG", "PK", "PA", "PY", "PE", "PH", "PR", "RU" , "SA", "RS", "SG", "SR", "CH", "TW", "TT", "TR", "UA", "GB", "US", "VE", "VN"
];