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

Pol’s picture

Assigned: Unassigned » Pol

...the map object is returned by reference...

Hello,

Could you point me where the map object is returned by reference ?

Thanks!

schultetwin’s picture

Sure. 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.

Pol’s picture

Status: Active » Fixed

I just checked indeed, thanks :-)

Just committed to dev.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.