Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It would be a good feature to be able to put the layer switcher outside the map, like this example:
http://openlayers.org/dev/examples/layerswitcher.html
or is there altready a way of doing this?
thanks,
joeysantiago
Comment | File | Size | Author |
---|---|---|---|
#4 | layerswitcherdiv-1475316_4.patch | 1.9 KB | evilehk |
Comments
Comment #1
joeysantiago CreditAttribution: joeysantiago commentedWell, a dirty solution has been putting this code in includes/behaviors/js/openlayers_behavior_layerswitcher.js , line 14:
probably it would be better to put also some code in the .inc file, in order to enable / disable the feature and add the id of the layer?
Comment #2
zzolo CreditAttribution: zzolo commentedHey @joeysantiago. Well, what you should do is just create a new layer switcher behavior that allows for that. You can put it in a custom module. This way you can maintain code easier on your project. But yes, this is the best way to go.
Comment #3
michaellenahan CreditAttribution: michaellenahan commentedThank you for this very useful thread!
Here's a Drupal 7 solution which I am working on.
Once again this is the dirty way to do it, hacking the openlayers module itself.
sites/all/modules/openlayers/plugins/behaviors/openlayers_behavior_layerswitcher.js
I'd be grateful for pointers on how to do this properly using a new layerswitcher behavior.
I'm not sure how to implement a new behavior, so my first thought was to override the js file using hook_js_alter().
I ran into this error:
Uncaught TypeError: Cannot call method 'addBehavior' of undefined
... in other words, Drupal.openlayers is not yet defined.
... so that's why for now, I'm unfortunately hacking the openlayers module itself.
For completeness, here is the rest of my custom openlayers_switcher module, it basically provides a block with the div for my layerswitcher to go into.
Comment #4
evilehk CreditAttribution: evilehk commentedI had the same issue of wanting to provide a div id for displaying the layerswitcher outside the map, and thank you michaellenahanu for sharing your module! I solved it in a similar manner, except I added a textfield in the layerswitcher fieldset of the behavior tab in the openlayers map edit screen. This way you can set different div ids for the layerswitcher per map. Here's the patch.
Comment #5
PolGreat patch ! committed !
You can also check this module, it might help: http://drupal.org/project/olebs
Comment #6
evilehk CreditAttribution: evilehk commentedThank you, Pol, and thanks for sharing your olebs module. I tried it out and it works great, especially with chosen.