显示鼠标停留处经纬度及高程值【已解决】
本帖最后由 就是那个胖子 于 2013-12-11 08:41 编辑从网上找的,可以实现,代码如下:
//显示鼠标所在位置处经纬度坐标及高程值
void CCustomOSGWnd::ShowLocation(osgViewer::Viewer* pViewer,osgEarth::MapNode* pMapNode)
{
//鼠标位置信息显示
osgEarth::Util::Formatter* formatter = new osgEarth::Util::LatLongFormatter();
osgEarth::Util::LabelControl* readout = new osgEarth::Util::LabelControl();
osgEarth::Util::ControlCanvas::get( pViewer, true )->addControl( readout );
readout->setFontSize(25.0);//设置字体大小
osgEarth::Util::MouseCoordsTool* tool = new osgEarth::Util::MouseCoordsTool( pMapNode );
tool->addCallback( new osgEarth::Util::MouseCoordsLabelCallback(readout, formatter) );
pViewer->addEventHandler( tool );
// add the state manipulator
pViewer->addEventHandler( new osgGA::StateSetManipulator(pViewer->getCamera()->getOrCreateStateSet()) );
// add the thread model handler
pViewer->addEventHandler(new osgViewer::ThreadingHandler);
// add the window size toggle handler
pViewer->addEventHandler(new osgViewer::WindowSizeHandler);
// add the stats handler
pViewer->addEventHandler(new osgViewer::StatsHandler);
// add the record camera path handler
pViewer->addEventHandler(new osgViewer::RecordCameraPathHandler);
// add the LOD Scale handler
pViewer->addEventHandler(new osgViewer::LODScaleHandler);
// add the screen capture handler
pViewer->addEventHandler(new osgViewer::ScreenCaptureHandler);
}
没添加高程数据,所以高程现在不正确,想请假下,怎么设置坐标在窗口显示的位置,函数里默认是0,0,看起来被挡住了,不知道怎么设置,求大神指点,谢谢 readout->setPosition(float x, float y); 本帖最后由 sck_dream 于 2013-10-30 10:23 编辑
楼主,我照你的方法实现的,但是出现坐标重叠问题(如图),请问知道是什么情况吗?
不添加.earth文件时候,空白球体的时候,没有这种情况,显示是正常的。 本帖最后由 就是那个胖子 于 2013-10-31 15:13 编辑
sck_dream 发表于 2013-10-30 10:18 static/image/common/back.gif
楼主,我照你的方法实现的,但是出现坐标重叠问题(如图),请问知道是什么情况吗?
不添加.earth文件时候 ...
不好意思哈,没遇到你这情况,你说的重叠是经纬度数值间的重叠?还是因为你设置的数据精度较长,显示的长度不够导致的重叠啊? 就是那个胖子 发表于 2013-10-31 10:35 static/image/common/back.gif
不好意思哈,没遇到你这情况,你说的重叠是经纬度数值间的重叠?还是因为你设置的数据精度较长,显示的 ...
是经纬度数值的重叠,好像有两个经纬度值,没有添加world.tif的时候,也就是显示白球的是数值是正确显示的,当加入数据的时候,就有重叠了。小弟刚学习,还望赐教!谢谢了。。。 sck_dream 发表于 2013-11-5 19:45 static/image/common/back.gif
是经纬度数值的重叠,好像有两个经纬度值,没有添加world.tif的时候,也就是显示白球的是数值是正确显示的 ...
我也是新手,不是很懂啊……你看看你是不是你原来的程序或者earth文件里也有显示坐标的功能,所以导致重叠现象, osgEarth::util这里面有个专门的已经做好的工具用来在显示经纬度的,你可以看一下源码
ysw 发表于 2013-11-23 08:49
osgEarth::util这里面有个专门的已经做好的工具用来在显示经纬度的,你可以看一下源码
谢谢 这个很有用,谢谢楼主。
页:
[1]