function ShowStationOnMap(stations) {
// 清除圖中的元素
map.graphics.clear();
// 設置顯示中心點及坐標
var location = new esri.geometry.Point(stations[0].longtitude, stations[0].latitude, map.spatialReference)
map.centerAndZoom(location, 8);
// 逐個添加元素
for (var s = 0; s < stations.length; s++) {
var symbol = new esri.symbol.PictureMarkerSymbol(stations[s].imageUrl, 18, 18);
var pt = new esri.geometry.Point(stations[s].longtitude, stations[s].latitude, map.spatialReference)
// 每個元素的屬性值
var attr = { "stationName": stations[s].stationName, "sId": stations[s].sId, "countryName": stations[s].countryName, "projectName": stations[s].projectName, "buildYear": stations[s].buildYear };
// 點擊該元素時的信息窗
var infoTemplate = new esri.InfoTemplate("${stationName}", "站點編號: ${sId}<br/>所屬項目: ${projectName} <br/>所屬區縣: ${countryName}
<br/>建成年份:${buildYear}<div><a href='javascript:ShowDetailStationPanel(" + stations[s].sId + ")'>查看詳情</a> </div>");
var graphic = new esri.Graphic(pt, symbol, attr, infoTemplate);
map.graphics.add(graphic);
}
}
當在外部點擊一個點時在地圖上顯示該數據的信息窗 這里用的是 map.infoWindow 和 infoTemplate 有點區別
var pt = new esri.geometry.Point(data.record.longtitude, data.record.latitude, map.spatialReference)
var attr = { "stationName": data.record.stationName, "sId": data.record.sId, "countryName": data.record.countryName, "projectName": data.record.projectName,
"buildYear": data.record.buildYear };
var infoTemplate = new esri.InfoTemplate("${stationName}", "站點編號: ${sId}<br/>所屬項目: ${projectName} <br/>所屬區縣: ${projectName} <br/>建成年份:
${buildYear}<div><a href='javascript:ShowDetailStationPanel(" + data.record.sId + ")'>查看詳情</a> </div>");
var symbol = new esri.symbol.PictureMarkerSymbol(data.record.imageUrl, 18, 18);
var graphic = new esri.Graphic(pt, symbol, attr, infoTemplate);
map.infoWindow.setContent(graphic.getContent());
map.infoWindow.setTitle(data.record.stationName);
map.infoWindow.show(pt, map.getInfoWindowAnchor(pt));
