韦小宝
unread,Jul 17, 2008, 10:16:15 PM7/17/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google 地图 API 讨论组
通过GMarker 标注地图上的位置。它实现 GOverlay 接口,因此用 GMap2.addOverlay() 方法添加到地图中。
其方法getPoint()可返回此标记锚定的地理坐标,返回值类型GLatLng
GEvent.addListener(gmapGoogleMap, 'click', mapClick);
function mapClick(marker, point) {
centerMarker = createMarker(point)
gmapGoogleMap.addOverlay(centerMarker);
centerMarker.openInfoWindowHtml(getMarkerText(centerMarker));
}
function createMarker(point, title) {
var cimage = "images/red-dot.png";
var icon = new GIcon();
icon.image = cimage;
icon.iconSize = new GSize(32, 32);
icon.iconAnchor = new GPoint(14, 32);
icon.infoWindowAnchor = new GPoint(14,0);
var cMarker = new GMarker(point,{icon:icon,draggable:true});
GEvent.addListener(cMarker, "click", function() {
cMarker.openInfoWindowHtml(getMarkerText(cMarker));
});
return cMarker;
}
function getMarkerText(cMarker){
return cMarker.getPoint()
}