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.
I have a page where I have the same page loaded twice (different sizes and centers, with the map centered at different points. These settings are change programmatically). When I call the openlayers_map_load function, the map object is returned by reference, which means any alterations I do to it are reflected next time I call openlayers_map_load to load the map again.
Comments
Comment #1
PolHello,
Could you point me where the map object is returned by reference ?
Thanks!
Comment #2
schultetwin CreditAttribution: schultetwin commentedSure. At the end openlayers_map_load(), we return a map object. Because it's an object, PHP automatically treats it as a reference. Ctools statically caches that map object, so if I call openlayers_map_load() twice, trying to load a map that has already been loaded I'll get a reference to the same map object. The function is not explicitly returning a reference but because all objects in PHP are references I just get a reference to the same map.
This may be a non-issue, and just expected behavior. I ran into this when trying to load the same map twice on a single page, and dynamically configuring it (changing to map object), which caused both instances of the map object to change.
Comment #3
PolI just checked indeed, thanks :-)
Just committed to dev.