//前提是google earth 已经在页面加载 即 ge!= null 否则报错
function addMarker(lng,lat,markerName,markerIconUrl,description)
//lng, lat为double 经纬度
//markerName为string标记旁显示的文本, markerIconUrl为自定义图标的url地址如:Http://www.aa.com/images/bb.png
//description标记的说明文字
{
var point = ge.createPoint('');
point.setLongitude(lng);
point.setLatitude(lat);
var placemark = ge.createPlacemark('');
placemark.setDescription(description);
placemark.setName(markerName);
// Define a custom icon.
var icon = ge.createIcon('');
icon.setHref(markerIconUrl);
var style = ge.createStyle(''); //create a new style
style.getIconStyle().setIcon(icon); //apply the icon to the style
placemark.setStyleSelector(style); //apply the style to the placemark
placemark.setGeometry(point);
ge.getFeatures().appendChild(placemark);
google.earth.addEventListener(placemark, 'click', onMarkerClick); //如果需要则添加placemark的鼠标单击响应
}
function onMarkerClick(event) // placemark的鼠标单击响应
{
event.preventDefault(); //使默认的响应失效
Do sth.
}