Question about how to handle Vector layers in GXP

34 views
Skip to first unread message

Ivan Willig

unread,
Jun 12, 2013, 3:38:42 PM6/12/13
to j...@opengeo.org
Hey,

I need to add a new OpenLayers.Layer.Vector layer to my geoexplorer
map. As a first pass I tried to simply add my layer via the
OpenLayers.Map object. How, I need to hide this layer in the Layer
Tree and the path to doing this was not very clear.

I started digging deeper and it seems like the correct way is to go
through the GXP Source Interface.

https://github.com/opengeo/gxp/blob/master/src/script/plugins/LayerSource.js

Are there examples of the correct of handling this? Should I just
subclass LayerSource with something like VectorSource and from there?

Thanks.

--
Ivan Willig
OpenGeo - http://opengeo.org

Bart van den Eijnden

unread,
Jun 12, 2013, 3:57:13 PM6/12/13
to j...@opengeo.org
Ivan,

please check out this code:


it's all you should need to do. No need to go through a source at all.

displayInLayerSwitcher: false takes care of hiding it from the tree.

For raising the layer to the top see:


Best regards,
Bart

-- 
Bart van den Eijnden
OpenGeo - http://opengeo.org
Expert service straight from the developers.



Ivan Willig

unread,
Jun 12, 2013, 3:57:41 PM6/12/13
to j...@opengeo.org
Lovely thanks Bart.
> --
> --
> http://groups.google.com/a/opengeo.org/group/js

Ivan Willig

unread,
Jun 12, 2013, 4:21:08 PM6/12/13
to j...@opengeo.org
From the docs it seems like this only really works the WFS Protocol,

https://github.com/opengeo/gxp/blob/master/src/script/plugins/FeatureManager.js#L712-L752

And it does not seem trivial to rip that part out.

Thoughts on this?

Bart van den Eijnden

unread,
Jun 12, 2013, 4:26:08 PM6/12/13
to j...@opengeo.org
The FeatureManager depends on WFS.

I'm not saying you should use the FeatureManager, I am only pointing you to relevant bits of code as inspiration for what you want to do.

Getting the FeatureManager to work with a different protocol is likely a non- trivial task.

Bart

Sent from my iPhone
> --
> --
> http://groups.google.com/a/opengeo.org/group/js
>
>
>

Ivan Willig

unread,
Jun 12, 2013, 4:28:17 PM6/12/13
to j...@opengeo.org
Cool,

Thats what I thought.

Thanks Bart.

On Wed, Jun 12, 2013 at 4:26 PM, Bart van den Eijnden
Reply all
Reply to author
Forward
0 new messages