簡體   English   中英

如何在openlayers標記上創建onclick事件?

[英]How can I create an onclick event on an openlayers marker?

這是我當前的代碼:

journey.path[x].marker = new OpenLayers.Marker(journey.path[x].curpoint,journey.path[x].markerIcon);
journey.path[x].marker.events.register('click', journey.path[x].marker, function(){alert('test');});
layer_device_markers.addMarker(journey.path[x].marker);

標記已添加到地圖,但警報尚未初始化。

控制台中也沒有錯誤。

嘗試這個:

journey.path[x].marker.events.register('mousedown', journey.path[x].marker, function(evt){
   alert('test');
   OpenLayers.Event.stop(evt); 
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM