首页 / 浏览问题 / 组件GIS / 问题详情
GeoText.Bounds.Width宽度问题
22EXP 2018年12月20日
为什么不同的GeoText获取到的宽度GeoText.Bounds.Width都是一样的,大概0.0000004左右

1个回答

您好!我测试没有重现您的问题哈~我运行代码及截图如下:

3,352EXP 2018年12月21日
我的GeoText是自己构建的,代码如下

           TextPart test = new TextPart();
            test.Text = "北京超图";
            test.AnchorPoint = new Point2D(100, 35);
            TextStyle testStyle = new TextStyle();
            testStyle.ForeColor = Color.Red;
            testStyle.FontHeight = 8;
            GeoText testText = new GeoText(test, testStyle);
            double width = testText.Bounds.Width;
            MessageBox.Show("GeoText的宽度是" + width);
您好!我这边测试了一下,添加字体与地图的比例尺有关系,您代码这样直接添加默认的比例尺是1:0.000004556多的,这样宽度计算下来也是对的。

那我这样测试,两个GeoText在地图上明明不一样宽,为什么读取到宽却是一样的

代码:

   Point2D testPoint = mapControl1.Map.PixelToMap(e.Location);
            TextPart test = new TextPart();
            test.Text = "北京超图";
            test.AnchorPoint = testPoint;
            TextStyle testStyle = new TextStyle();
            testStyle.ForeColor = Color.Red;
            testStyle.FontHeight = 8;
            GeoText testText = new GeoText(test, testStyle);
            double width = testText.Bounds.Width;
            mapControl1.Map.TrackingLayer.Add(testText, "");

            Point2D offPoint = new Point2D(testPoint.X, testPoint.Y + 10);
            TextPart test1 = new TextPart();
            test1.Text = "北京超图技术问答社区";
            test1.AnchorPoint = offPoint;
            TextStyle testStyle1 = new TextStyle();
            testStyle1.ForeColor = Color.Red;
            testStyle1.FontHeight = 10;
            GeoText testText1 = new GeoText(test1, testStyle1);
            double width1 = testText1.Bounds.Width;
            mapControl1.Map.TrackingLayer.Add(testText1, "");
            mapControl1.Map.RefreshTrackingLayer();
            MessageBox.Show("GeoText的宽度是" + width + "\r\n" + "GeoText1的宽度是:" + width1);
这个我可以给您举个例子,0.0000456789123674674与0.00004567891236775678是有区别的,但是如果只显示前面的小数点后面的8位那都是0.00004567。

来,你看看有区别吗,你有没有自己测试一下???

加入这行代码testStyle.IsSizeFixed = false ; 只是固定大小为true 的时候 ,值很小很小  

可能是底层限制了最低值
...