arcgis for js之描點
//座標
var point = new esri.geometry.Point(x, y, map.spatialReference);
//圖形的樣式
var symbolurl=“img/pic.jpg”;
//建立
var symbol = new esri.symbol.PictureMarkerSymbol({
"url" : symbolurl, //圖示路徑
"width" : 5, //圖示的寬度
"height" : 5 //圖示的高度
});
//元素屬性
attr = { "type" : "drp",
"x" : point.x,
"y" : point.y,
"stcd" : stcd,
"stnm" : stnm,
"drp" : drp
};
//資訊窗
var infoTemplate = new esri.InfoTemplate();
var content = '<div>' + '站點名稱:' + stnm + '<br/>' + '雨量:' + drp+ ' mm</div>';
// 設定資訊窗的標題和內容
infoTemplate.setContent(content);
infoTemplate.setTitle(“降雨”);
//建立圖形
var g = new esri.Graphic(point,symbol,attr,infoTemplate );
//圖層新增圖形
rainlayer.add(g);
//當在外部點選一個點時在地圖上顯示該資料的資訊窗
map.infoWindow.setContent(content);
map.infoWindow.setTitle(stnm);
map.infoWindow.show(point);