Quantcast

Restyling ModelLayer in MapNode. Is there a better way?

classic Classic list List threaded Threaded
1 message Options
John Larring John Larring
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Restyling ModelLayer in MapNode. Is there a better way?

Hi,

Does any know a more elegant way to restyle an existing model layer in a map node?

<tt>
    // Begin operation
    map_node_->getMap()->beginUpdate();
    // Remove layer with new style
    map_node_->getMap()->removeModelLayer(model_layer_.get());

    // Extract feature model source options
    osgEarth::Features::FeatureModelSourceOptions fms_opts(model_layer_->getModelLayerOptions().driver().get());
    // Set new style sheet with new styles
    fms_opts.styles() = my_new_stylesheet;

    // Create and add new model layer based on previous options and new style
    osgEarth::ModelLayerOptions ml_opts(model_layer_->getName(), fms_opts);
    model_layer_ = new osgEarth::ModelLayer(ml_opts);
    map_node_->getMap()->addModelLayer(model_layer_.get());

    // End operation
    map_node_->getMap()->endUpdate();
</tt>

Best regards,
John
Loading...