參考論壇一些朋友的帖子實現點的在線添加但是也存在問題問題是新加入的點在WebContent進行刷新後不能馬上顯示出來需要重新打開一個浏覽器窗口浏覽才能看到剛加入的點希望大家給予指導謝謝
public void addPoint(MapEvent event){
AGSLocalMapResource res = (AGSLocalMapResource)thiswebContextgetResources()get(ags);
try{
// 建立一個工作空間工廠對象並設置它的參數信息
SdeWorkspaceFactory sdewf = (SdeWorkspaceFactory)resgetServerContext()createObject(SdeWorkspaceFactorygetClsid());
PropertySet pset = (PropertySet)resgetServerContext()createObject(PropertySetgetClsid());
psetsetProperty(SERVER gxk);// 服務器名稱
psetsetProperty(INSTANCE );// 實例名
psetsetProperty(USER sa); // SDE數據表空間的用戶名
psetsetProperty(PASSWORD sa);// 密碼
psetsetProperty(VERSION DBOgxk);// SDE數據的版本
Workspace iws =(Workspace) sdewfopen(pset );
WebPoint screenPoint = (WebPoint)eventgetWebGeometry();
WebMap mapctrl = eventgetWebContext()getWebMap();
WebPoint mappnt =WebPointtoMapPoint(screenPoint mapctrlgetCurrentExtent() (int)mapctrlgetWidth() (int)mapctrlgetHeight());
Geometry soapgeo=AGSUtiltoAGSGeometry(mappnt);
String soapString = comesriadfwebagsutilAGSUtilserializeStub(soapgeo);
soapString = soapStringreplaceAll(xsi:type=\soapenc:Array\ );
IPoint mypoint = (IPoint)AGSUtildeserializeArcObject(soapString resgetServerContext());
IWorkspaceEdit wse = (IWorkspaceEdit)iws;
wsestartEditing(false);
wsestartEditOperation();
IFeatureClass featureclass = iwsopenFeatureClass(sdeDBORespt);
IFeature feature = featureclasscreateFeature();
featuresetShapeByRef((IGeometry)mypoint);
featuresetValue(featuregetFields()findField(NAME) kkk);
featurestore();
wsestopEditOperation();
wsestopEditing(true);
thiswebContextrefresh();
}catch(Exception e){
eprintStackTrace();
}
}
刷新地圖後不能顯示新加入的數據的原因是由於在開始編輯時新打開了一個工作空間該工作空間並不是浏覽器中看到地圖所在的工作空間
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26999.html