If an Openlayers map is included in a form that uses #ajax, Drupal.detachBehaviors() is run by Drupal core's ajax code, which results in the map being deleted from Drupal.openlayers.instances[map_id].
The map itself is not destroyed - just the storage of the instance in Drupal.openlayers.instances. I'm not sure if there is a reason for this.
I am trying to write Javascript that adds layers to the map dynamically after it is loaded, and the only way for me to access the Openlayers map object is to use Drupal.openlayers.getMapById() - but that doesn't work when Drupal.openlayers.instances isn't populated.
Comment | File | Size | Author |
---|---|---|---|
#5 | openlayers_detach-2688029-5.patch | 593 bytes | m.stenta |
| |||
#2 | openlayers_detach-2688029-1.patch | 651 bytes | m.stenta |
|
Comments
Comment #2
m.stentaAttached is a patch that reverts just one part of this commit: http://cgit.drupalcode.org/openlayers/commit/?h=7.x-2.x&id=28cdc1c0bd275...
I'm not sure if there was a reason for adding that code - or if perhaps it was just for cleanup purposes. That makes sense, but I think it's unnecessary in this instance.
Comment #4
m.stentaThis patch breaks AJAX map replacements. Need to figure out a different solution. See #2755899: Geocode button doesn't work
Comment #5
m.stentaOk, after some debugging, I discovered that it simply needs "context" included in the call to jQuery!
Here is a much simpler patch, which solves the original issue, and does not cause conflicts as described in #2755899: Geocode button doesn't work
Comment #7
m.stentaComment #9
PolNice catch !
Thanks !!!