Javascript Openlayers如何向标记添加链接

Javascript Openlayers如何向标记添加链接,javascript,openlayers,Javascript,Openlayers,我已经在这个论坛上搜索过这个主题,但是我无法添加到我的标记的链接 这是我的实际工作代码: <!doctype html> <html lang="en"> <head> <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.5.0/css/ol.

我已经在这个论坛上搜索过这个主题,但是我无法添加到我的标记的链接

这是我的实际工作代码:

<!doctype html>
<html lang="en">
  <head>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.5.0/css/ol.css" type="text/css">
    <script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.5.0/build/ol.js"></script>
    <title>Cerkiew Świętego Mikołaja w Białymstoku</title>
  </head>
  <body>
    <div id="map" class="map"></div>
    <script type="text/javascript">
    var map = new ol.Map({
        target: 'map',
        layers: [
            new ol.layer.Tile({
                source: new ol.source.OSM()
            })
        ],
        view: new ol.View({
            center: ol.proj.fromLonLat([23.154491, 53.132705]), zoom: 18
        })
    });
    //add markers
    var markers = new ol.layer.Vector({
        source: new ol.source.Vector(),
        style:
        new ol.style.Style({
            image: new ol.style.Icon({
                anchor: [0.5, 1],
                src: 'https://www.historia3d.pl/wp-content/uploads/2021/05/Pin.png'
            })
        })
    });
    map.addLayer(markers);
    
    //add single marker
    var marker = new ol.Feature(new ol.geom.Point(ol.proj.fromLonLat([23.154491, 53.132705])));
    markers.getSource().addFeature(marker);
    </script>
  </body>
</html>
但是,当我尝试在代码中添加这一行时,web开始在循环中重新加载


您能帮助我吗?

您需要倾听地图上的点击,确定该点上有哪些功能,然后打开相应的链接,例如
marker.addEventListener('click', window.location.href='mylink');