gwaldron/osgearth

Pick objects from OGRFeatureSource

Closed this issue · 2 comments

gd-6 commented

Hey there, I'm trying to grab objects from an OGRFeatureSource (shapefile). For instance, in the osgearth_city example, I want to pick a road or a park and get the field values for that object from the shapefile data.
I've tried using GUIEventHandler from the osg_pick example and ObjectIDPicker from osgearth_pick, but no luck with either of them. Any ideas on how to make this work?

Make sure you enable picking on your layer by setting the feature-indexing option. Do this before opening the layer or adding it to the map:

layer->options().featureIndexing()->enabled() = true;

Or in the earth file you can just say

pickable="true"
gd-6 commented

Thanks !