他的使用方法介绍如下:
1、 主要属性
Property |
Type |
Description |
anchor |
String |
Placement of the InfoWindow with respect to the graphic. See the Constants table for values. Infowindow的显示位置,具体请看其“常量“设置 |
coords |
Point |
The anchor point of the InfoWindow in screen coordinates. 信息窗口所在的坐标点 |
fixedAnchor |
String |
InfoWindow always show with the specified anchor. See the Constants table for values. 指定的显示位置 |
isShowing |
Boolean |
Determines whether the InfoWindow is currently shown on the map. 判断信息窗口的显示状态 |
2、 常量:
ANCHOR_LOWERLEFT |
窗口位于点的左下 |
ANCHOR_LOWERRIGHT |
InfoWindow is anchored to the lower right of the point. 右下 |
ANCHOR_UPPERLEFT |
InfoWindow is anchored to the upper left of the point.左上 |
ANCHOR_UPPERRIGHT |
InfoWindow is anchored to the upper right of the point.右上 |
3、 方法:
Method |
Return Value |
Description |
hide() |
none |
隐藏信息窗口 |
move(point) |
none |
Moves the InfoWindow to the specified screen point. 移动信息框到指定点 |
resize(width, height) |
none |
Resizes the InfoWindow to the specified height and width in pixels.改变信息框大小 |
setContent(stringOrDOMNode) |
InfoWindow |
Sets the content in the InfoWindow.设置信息窗口的内容 |
setFixedAnchor(anchor) |
none |
Sets the fixed location of the InfoWindow anchor. Valid values are listed in the Constants table.设置显示位置 Anchor参数为上面的常量类型 |
setTitle(title) |
InfoWindow |
Sets the title for the InfoWindow. 设置窗口的标题 |
show(point, anchor) |
none |
Shows the InfoWindow at the specified screen point and anchor. Valid values are listed in the Constants table. 显示信息框(位置点,位置) |
4、 事件:
onHide() |
隐藏窗口时的事件 |
onShow() |
显示窗口时的事件 |
5、 使用实例:
function infowindow(evt)
{
map.infoWindow.setTitle("Coordinates");
map.infoWindow.setContent("lat/lon : " + evt.mapPoint.y + ", " + evt.mapPoint.x +
"<br />screen x/y : " + evt.screenPoint.x + ", " + evt.screenPoint.y);
map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint));
}
map.getInfoWindowAnchor(evt.screenPoint):为获取系统建议的显示位置,这样写可以使窗口尽量显示在屏幕中最佳位置!!