When implementing map alters it's useful to have access to the map preset name.
This could be done by adding the preset name to the $map array passed around
or passing the map preset name to the hooks.

I'm fine with both, and ready to make a patch.
Comments welcome on pro/cons of each approach.

CommentFileSizeAuthor
#2 preset_name_in_map_data.patch848 bytesstrk
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zzolo’s picture

+1 on this. It will definitely be useful on the map alters. I would suggest putting the preset name into the map array so that it could be used in other places if necessary, as well as updating the passing of argument seems unnecessary and could possibly break the use of the hooks (but probably not).

strk’s picture

FileSize
848 bytes

The attached patch adds 'preset_name' attribute to the preset data (the one being passed around to hooks and also containing the 'id').

Note that (for future improvements/cleanups) openlayers_render_map, which currently takes an optional preset_name, might get it from first argument if not explicitly overridden by caller (didn't touch that code in this patch).

strk’s picture

Or maybe, another approach, is that IFF a preset is available, $preset->data['preset'] = $preset
That way we'd have all preset informations available, and probably with no data copies ($preset being a stdClass).

strk’s picture

Uhm, tried the approach in previous comment, but it will have troubles serializing the recursion:

warning: json_encode(): recursion detected in modules/openlayers/openlayers.module on line 179.warning: json_encode(): recursion detected in modules/openlayers/openlayers.module on line 179.

Well, 'preset_name' is good enough for now...

strk’s picture

Status: Active » Needs review
strk’s picture

Status: Needs review » Fixed
strk’s picture

Excellent start with CVS... correct commit is here: http://drupal.org/cvs?commit=395870

Status: Fixed » Closed (fixed)

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