unable to select a label #2565
Answered
by
gwaldron
AhmedAredah
asked this question in
Support Q&A
-
I have an application that features the OSGEarth, it adds multiple labels to the earth model and the user is expected to select multiple of these labels by clicking. However, I am unable to select any label and the pick function does not get called. I would appreciate any help on that. I tried to follow the osgEarth_pick.cpp here is the relative chunk of code that I believe is related:
|
Beta Was this translation helpful? Give feedback.
Answered by
gwaldron
Jun 26, 2024
Replies: 1 comment 1 reply
-
You do need to auto anno = new PlaceNode();
anno->setText("Hello, World!");
anno->setPosition(GeoPoint(mapnode->getMapSRS(), -122.5, 45.5));
Registry::objectIndex()->tagNode(anno, anno);
mapnode->addChild(anno);
auto picker = new ObjectIDPicker();
picker->setView(&viewer);
picker->setGraph(mapnode);
mapnode->addChild(picker);
picker->onClick([&](const ObjectID& id)
{
if (id != OSGEARTH_OBJECTID_EMPTY)
{
auto place = Registry::objectIndex()->get<AnnotationNode>(id);
if (place)
{
std::cout << "Clicked on \"" << place->getText() << "\"" << std::endl;
}
}
}); Hope this helps! |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
AhmedAredah
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You do need to
tag
your annotation to make it clickable. (You commented this out.)Here's a simple code snippet that works: