/**
* 显示地图点.
* json的格式[{"name":"name1","x":"x1","y":"y1","img":"img1","content":"content1"}...]
*/ //地图上显示这些企业点
function displayPoints(json){
var layer = esri.layers.GraphicsLayer({id:"layer"});
$.each(json, function(index){ var x = this.x;
var y = this.y;
//var x = Math.round(Math.random()*360-180);
//var y = Math.round(Math.random()*180-90);
var img = this.img;
var pt = new esri.geometry.Point([x,y]);
var pictureMarkerSymbol = new esri.symbol.PictureMarkerSymbol(img, 20, 20);
var g = new esri.Graphic(pt, pictureMarkerSymbol);
var template = new esri.InfoTemplate();
template.setTitle(this.name);
template.setContent("<b>项目建设内容:</b>"+this.XMJSNR+"<br/ ><br/ >"+"<b>责任单位:</b>"+this.ZRDW);
g.setInfoTemplate(template);
layer.add(g);
});
map.addLayer(layer);
}
-------------
附加:js中将json串转换成json对象的jquery方法:var obj = JSON.parse(data);