修改文件MapEvent.js 加入代码 MapEvent.RIGHTCLICK="event.rightclick";
修改MapPaneWidget.js 在this.customEvent = function(eventName) {//……}中加入代码
if (eventName == MapEvent.RIGHTCLICK) {
var _littleo=this.model;
mapDiv.onmousedown = function(e) {
var e = e || window.event;
var btnCode;
if ('object' == typeof e){
btnCode = e.button;
if(btnCode==2) {
eval("var rClick="+_littleo.events[MapEvent.RIGHTCLICK]+";");
eval(rClick(e));
}
else{
mapMDown(e, mapDiv, s);
}
}
}
}
示例代码
// 在地图上加入右键事件
MapEvent.addListener(map, MapEvent.RIGHTCLICK, function(e) {
var coord = MapEvent.getEventCoord(e, map);
var marker = new Marker(coord.getPoint(), Marker.LARGE);
map.addOverlay(marker);
marker.setInfo("Hello! it's marker: <a href=\"http://www.hymake.com\" target=\"_blank\">#" + marker.getId() + "</a>");
});文件