//值得注意:GMarker标注类型支持“Click”事件,但其他类型的标记,如以画线方式标示路线或范围的GPolyline则是不支持事件单击响应的。 GDownloadUrl("servlet/KmlParseForCoordinate_servelt",function(data){ var arrayObj = data.split("%"); for(var index = 0; index < arrayObj.length; index++){ var polylineObj = arrayObj[index].split("#"); var polyLineFromApp = polylineObj[0]; polyLineFromApp = "" + polyLineFromApp; var lev = polylineObj[1]; lev = ""+lev; polyline = new GPolyline.fromEncoded({ color:"#0000EE", weight:3, points:polyLineFromApp, levels:lev, zoomFactor:32, numLevels:3 }); map.addOverlay(polyline); } }); 解决办法,编写一个自定义按钮控件(control.js): /*TextControl类 ============================================================================ *添加按钮扩展, *继承自GControl() *value--按钮的value 值 *left--按钮与左边框的距离(像素) *top--按钮与上边框的距离(像素) */ function TextControl(value,left,top,clickFunction) { this.value_ = value||"按钮"; //================== this.id = "runcode"; this.left_ = left||77; this.top_ = top||7; this.clickFunction_ = clickFunction; } TextControl.prototype = new GControl(); TextControl.prototype.initialize = function(map) { var container = document.createElement("div"); var containerDiv = document.createElement("div"); this.setButtonStyle_(containerDiv); container.appendChild(containerDiv); containerDiv.appendChild(document.createTextNode(this.value_)); GEvent.addDomListener(containerDiv, "click", this.clickFunction_); this.map_ = map; this.map_.getContainer().appendChild(container); return container; } TextControl.prototype.getDefaultPosition = function() { return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(this.left_,this.top_)); } TextControl.prototype.setButtonStyle_ = function(button) { button.style.color = "#000000"; button.style.backgroundColor = "white"; button.style.font = "12px '宋体'"; button.style.border = "1px solid black"; button.style.padding = "2px"; button.style.marginBottom = "3px"; button.style.textAlign = "center"; button.style.width = "4em"; button.style.cursor = "pointer"; } 然后在页面中添加: <mce:script src="./scripts/control.js" mce_src="scripts/control.js" type="text/javascript"></mce:script> function load() { if (GBrowserIsCompatible()) { ..... map.addControl(new TextControl("添加",77,7,addPlaceMark)); ..... } } function addPlaceMark(){ //这样GMarker标注类型就可以支持“Click”事件 map.removeOverlay(polyline); }