技术点:
var graphicStr=dojo.toJson(geometry.toJson()); //使用dojo将json串解析成string的json,可以保存整个graphicStr;也可以使用geometry.toJson().rings的方式获取点位信息,可以将geometry.toJson().rings存入数据库;
我在项目中用到显示面信息的代码 其中gismian为所有坐标信息;
var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.25]));
var mian = new esri.geometry.Polygon(new esri.SpatialReference({wkid:2383}));
var rings = new Array();
var rs = gismian.split(",");
for(var i = 0;i<rs.length;i=i+2){
var j = 0;
rings.push([Number(rs[i]),Number([rs[i+1]])]);
j++;
}
mian.addRing(rings);
var graphic = new esri.Graphic(mian, symbol);
//清除上一次的画图内容
map.graphics.clear();
map.graphics.add(graphic);
var mian = new esri.geometry.Polygon(new esri.SpatialReference({wkid:2383}));
var rings = new Array();
var rs = gismian.split(",");
for(var i = 0;i<rs.length;i=i+2){
var j = 0;
rings.push([Number(rs[i]),Number([rs[i+1]])]);
j++;
}
mian.addRing(rings);
var graphic = new esri.Graphic(mian, symbol);
//清除上一次的画图内容
map.graphics.clear();
map.graphics.add(graphic);