Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot change icon of a PlaceNode after being added to the map #2667

Open
AhmedAredah opened this issue Dec 6, 2024 · 3 comments
Open

Cannot change icon of a PlaceNode after being added to the map #2667

AhmedAredah opened this issue Dec 6, 2024 · 3 comments
Assignees
Labels
defect It's busted

Comments

@AhmedAredah
Copy link

osgEarth Version (required): 3.4

Description of the problem: icon does not change by setStyle(style)

What you have tried: I am trying to change the icons using code after assigning an initial icon when i was creating the node as below:

      osgEarth::PlaceNode* label =
          new osgEarth::PlaceNode(
              osgEarth::GeoPoint(
                  geoSRS,
                  port->getPortCoordinate().getLongitude().value(),
                  port->getPortCoordinate().getLatitude().value(), 0,
                  osgEarth::AltitudeMode::ALTMODE_ABSOLUTE),
              labelText.toStdString(),
              _normalStyle);
                        

Screenshot, code block, or data file that will help reproduce the issue:

    void toggleHighlightNode(const osgEarth::ObjectID& id) {
        auto node =
            osgEarth::Registry::objectIndex()->get<osgEarth::PlaceNode>(id);
        if (!node) return;

        auto it = _highlightedNodes.find(node);
        if (it != _highlightedNodes.end()) {
            node->setStyle(_normalStyle);
            _highlightedNodes.erase(it);
        } else {
            node->setStyle(_highlightStyle);
            _highlightedNodes.insert(node);
        }
        node->dirty();
    }
@gwaldron
Copy link
Owner

gwaldron commented Dec 9, 2024

This may be a bug in PlaceNode; as a workaround, try calling PlaceNode::setIconImage() directly and see if that works.

@AhmedAredah
Copy link
Author

Thank you. This worked.

@gwaldron gwaldron added the defect It's busted label Dec 10, 2024
@gwaldron gwaldron self-assigned this Dec 10, 2024
@gwaldron
Copy link
Owner

Thanks for reporting back.
I have marked this as a defect and will put it in the queue to patch up for the trunk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect It's busted
Projects
None yet
Development

No branches or pull requests

2 participants