soe 如何设置标签?
SOE里面,已经能够绘制点、线、面,并设置显示风格。请问如何显示标签?
我写的代码,标签不起作用,不能显示label。
private JsonObject getPointJsonObject()
{
JsonObject pRest = new JsonObject();
pRest.AddString("layerName", "cwpoint");
pRest.AddString("displayFieldName", "name");
pRest.AddString("geometryType", "esriGeometryPoint");
JsonObject pSpatial = new JsonObject();
pSpatial.AddString("wkid", "4490");
pRest.AddJsonObject("spatialReference", pSpatial);
JsonObject Feature1 = new JsonObject();
JsonObject attributes = new JsonObject();
attributes.AddString("name", "aaaaaaaaa");
attributes.AddString("CLASS", "bbbbbbbb");
attributes.AddString("ST", "ccccccccccc");
Feature1.AddJsonObject("attributes", attributes);
IPoint ppt1 = new PointClass();
ppt1.PutCoords(112.34, 40);
JsonObject ppt1JO=Conversion.ToJsonObject(ppt1 as IGeometry);
Feature1.AddJsonObject("geometry", ppt1JO);
JsonObject[] pFea = new JsonObject[1];
pFea[0] = Feature1;
pRest.AddArray("features", pFea);
ILabelEngineLayerProperties pLableEngine = new LabelEngineLayerPropertiesClass();
pLableEngine.Expression = "[" + "name" + "]";
JsonObject drawingInfo = new JsonObject();
drawingInfo.AddBoolean("showLabels", true);
JsonObject labelingInfo = new JsonObject();
labelingInfo.AddString("labelPlacement", "esriServerPointLabelPlacementBelowCenter");
labelingInfo.AddObject("labelExpression", pLableEngine.Expression);
labelingInfo.AddBoolean("useCodedValues", false);
JsonObject Txtsymbol = new JsonObject();
Txtsymbol.AddString("type", "esriTS");
object[] colorArray1 = new object[] { 78, 78, 78, 255 };
Txtsymbol.AddArray("color", colorArray1);
Txtsymbol.AddString("verticalAlignment", "bottom");
Txtsymbol.AddString("horizontalAlignment", "left");
JsonObject TxtFontsymbol = new JsonObject();
TxtFontsymbol.AddString("family", "Arial");
TxtFontsymbol.AddString("size", "9");
TxtFontsymbol.AddString("style", "normal");
TxtFontsymbol.AddString("weight", "bold");
TxtFontsymbol.AddString("decoration", "none");
Txtsymbol.AddJsonObject("font", TxtFontsymbol);
labelingInfo.AddJsonObject("symbol", Txtsymbol);
labelingInfo.AddString("minScale", "0");
labelingInfo.AddString("maxScale", "0");
drawingInfo.AddJsonObject("labelingInfo", labelingInfo);
pRest.AddJsonObject("drawingInfo", drawingInfo);
return pRest;
}
我写的代码,标签不起作用,不能显示label。
private JsonObject getPointJsonObject()
{
JsonObject pRest = new JsonObject();
pRest.AddString("layerName", "cwpoint");
pRest.AddString("displayFieldName", "name");
pRest.AddString("geometryType", "esriGeometryPoint");
JsonObject pSpatial = new JsonObject();
pSpatial.AddString("wkid", "4490");
pRest.AddJsonObject("spatialReference", pSpatial);
JsonObject Feature1 = new JsonObject();
JsonObject attributes = new JsonObject();
attributes.AddString("name", "aaaaaaaaa");
attributes.AddString("CLASS", "bbbbbbbb");
attributes.AddString("ST", "ccccccccccc");
Feature1.AddJsonObject("attributes", attributes);
IPoint ppt1 = new PointClass();
ppt1.PutCoords(112.34, 40);
JsonObject ppt1JO=Conversion.ToJsonObject(ppt1 as IGeometry);
Feature1.AddJsonObject("geometry", ppt1JO);
JsonObject[] pFea = new JsonObject[1];
pFea[0] = Feature1;
pRest.AddArray("features", pFea);
ILabelEngineLayerProperties pLableEngine = new LabelEngineLayerPropertiesClass();
pLableEngine.Expression = "[" + "name" + "]";
JsonObject drawingInfo = new JsonObject();
drawingInfo.AddBoolean("showLabels", true);
JsonObject labelingInfo = new JsonObject();
labelingInfo.AddString("labelPlacement", "esriServerPointLabelPlacementBelowCenter");
labelingInfo.AddObject("labelExpression", pLableEngine.Expression);
labelingInfo.AddBoolean("useCodedValues", false);
JsonObject Txtsymbol = new JsonObject();
Txtsymbol.AddString("type", "esriTS");
object[] colorArray1 = new object[] { 78, 78, 78, 255 };
Txtsymbol.AddArray("color", colorArray1);
Txtsymbol.AddString("verticalAlignment", "bottom");
Txtsymbol.AddString("horizontalAlignment", "left");
JsonObject TxtFontsymbol = new JsonObject();
TxtFontsymbol.AddString("family", "Arial");
TxtFontsymbol.AddString("size", "9");
TxtFontsymbol.AddString("style", "normal");
TxtFontsymbol.AddString("weight", "bold");
TxtFontsymbol.AddString("decoration", "none");
Txtsymbol.AddJsonObject("font", TxtFontsymbol);
labelingInfo.AddJsonObject("symbol", Txtsymbol);
labelingInfo.AddString("minScale", "0");
labelingInfo.AddString("maxScale", "0");
drawingInfo.AddJsonObject("labelingInfo", labelingInfo);
pRest.AddJsonObject("drawingInfo", drawingInfo);
return pRest;
}
1 个回复
skyty
赞同来自:
要回复问题请先登录或注册