js客户端,我画了多边形后,通过设置lable作为名称描述,怎么让这个lable信息在多边形内部呢;我查看api可以设置labelYOffset,labelXOffset偏移;我设置便宜后,缩放时,lable信息就跑远了,如何设置让他们相对位置保持不变呢,谢谢!!
谢谢您,
我是给多边形设置label,我在系统的地图上测试了下,确实文字在质心上;然后在我的CAD转换的地图上就偏了;代码见下:
// x1=x2 y2=y3 x3=x4 y4=y1 var polygon_data=[ [572047,5225290], [572047,5225270], [572020,5225270], [572020,5225290] ]; var points=[]; for(var i= 0,len=polygon_data.length;i<len;i++){ var point = new SuperMap.Geometry.Point(polygon_data[i][0],polygon_data[i][1]); points.push(point); } var linearRing=new SuperMap.Geometry.LinearRing(points); var polygon=new SuperMap.Geometry.Polygon([linearRing]); //属性数据 var polygon_data = {"train_no":"100100","train_name":"你猜"}; //指定样式 var drawFeatureStyle = { strokeColor: "#FF0000", strokeWidth: 2, strokeOpacity: 0.8, pointRadius: 6, fillColor: "#0000FF", fillOpacity: 0.5, cursor: "pointer", label:"多边形描述信息",//多边形描述信息 fontFamily:"宋体",//标签字体 fontColor:"#00FF00", labelXOffset:20, labelYOffset:20, labelSelect:true }; var polygon_feature=new SuperMap.Feature.Vector(polygon,polygon_data,drawFeatureStyle);polygonLayer.addFeatures([circleVector1,polygon_feature]);