Hello, I notice an issue with openlayers behaviour. Basically in browser console I get the error message: Cannot read property 'map_name' of undefined When I check maps object in console: Drupal.settings.openlayers.maps
I get this: Object {openlayers-map: undefined}
In map configuration Layers & Styles in OVERLAY LAYERS section I selected my custom layer which is based on view (Layer Type: OpenLayers views) but if I select a different layer in OVERLAY LAYERS section for example "Placeholder for Geofield Formatter" then I can get maps object. I don't know what wrong is but it worked before I updated openlayers module. I need to get to this object because my custom module stop working because of that.
If you need more information or you can't recreate the issue, please let me know.
Thank you
Comment | File | Size | Author |
---|---|---|---|
#11 | layers_and_styles.png | 43 KB | rafalB |
#11 | javascript_openlayers_object.png | 417.84 KB | rafalB |
#2 | map.tgz | 5.36 KB | rafalB |
Comments
Comment #1
PolHi,
I'm not able to reproduce the error, could you check with the latest development version ?
Thanks
Comment #2
rafalB CreditAttribution: rafalB commentedHi Pol, thank you for your response, I've just tried with the latest development version and I got the same issue. Now I don't get the message Cannot read property 'map_name' of undefined but I still can't get the maps object in a browser console. Currently all modules which I am using with open layers they are up to date the same Drupal core. I've noticed that I can't get maps object with Drupal.settings.openlayers.maps
but when I look at html source in browser I can see javascript code with all those settings. I am assuming that the code might be broken but I might be wrong.
I created a feature so you should be able to recreate it. The feature contains content type, view, and openlayers settings.
Please let me know if you need more details.
Comment #3
rafalB CreditAttribution: rafalB commentedComment #4
PolWorking on it.
Comment #5
PolI have committed two fix which are probably a part of the solution.
First one: http://drupalcode.org/project/openlayers.git/commit/f49bcd1
Second one: http://drupalcode.org/project/openlayers.git/commit/dcec6c3
The second fix is just a fix of the first one.
Could you test with the 7.x-2.x version and report back ? thanks !
Comment #6
rafalB CreditAttribution: rafalB commentedHi Pol, I've just tested the latest version 7.x-2.x and I still have the same issue, I can't get full maps object, in console I get:
opelayers-map: undefined
probably by broken javascript but I might be wrong.Comment #7
PolI'm sorry, I'm not able to reproduce the problem.
I reverted your feature, so I have cancelled my changes and with OL 7.x-2.x I have not a single error and the map is displayed correctly.
I'll close it, reopen if needed.
Comment #8
rafalB CreditAttribution: rafalB commentedHi Pol, the map is displayed correctly for me as well, in fact it wasn't a problem, my problem is that I can't get the full javascript object in browser console for maps, basically comment #2 explains everything. Could you tell me what you get if you enter
Drupal.settings.openlayers.maps
in browser console? Thank you.Comment #9
rafalB CreditAttribution: rafalB commentedComment #10
PolIndeed, I'm unable to retrieve the JS object using that method.
Nevertheless, you can use:
jQuery("#openlayers-map").data().openlayers.map
To get it, and this is the best method to use to get it.
Comment #11
rafalB CreditAttribution: rafalB commentedThank you Pol for your answer, I am going to use your way to get the JS object. BTW it is weird that the method
Drupal.settings.openlayers.maps
doesn't work anymore. I used it before and it worked for me, I still think that javascript is broken because javascript in header has the Drupal.settings.openlayers structure but for some reasons the javascript is never performed.I noticed that it happens only for custom OVERLAY LAYERS but if you select for example
layers in Layers & styles tab then you can access to JS object with
Drupal.settings.openlayers.maps
I am not sure if it is a bug or it should work like that but for me the behaviour has been changed since I updated version to the latest one.
I think it would be worth to fix it. Anyway thank you for your help.
Comment #12
PolI suppose that it's a problem caused by geofield.
If you use a previous beta version of OpenLayers, do you have the same ?
Maybe we should have a look at this file ?
Comment #13
zaporylieFor me it doesn't matter if I have Geofield on or off. Probably for rafalB as well. The problem is any layer on initially hidden map.
This code (inside try {}) throws exception:
/openlayers/js/openlayers.js (lines 83-84).
So this code will be never executed:
Workaround is to hide openlayer map with jQuery
.hide()
method instead of CSSdisplay: none;