Skip to content

Getting screen (x,y) from lat/lon #2496

Closed Answered by gwaldron
Warren-Whitfield asked this question in Support Q&A
Discussion options

You must be logged in to vote

Excuse any typos.

GeoPoint map_coords;
...
// convert your map coordinates to world coords:
osg::Vec3d world;
map_coords.toWorld(world);
...
// convert world coords to screen coords. For this you need an osg::Camera.
auto V = camera->getViewMatrix();
auto P = camera->getProjectionMatrix();
auto W = camera->getViewport()->computeWindowMatrix();
auto screen_coords = world * (V * P * W);

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by gwaldron
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants