I want to be able to add my own custom text/layout to the 'label' portion of a gmap - the shaded pop-up dialog box that comes up. You have hard coded a few cases, such as acidfree and image. My specific need is (well, was, I have a patch for you) to display a particular flexinode correctly for the content it models. The following patch worked (it is against cvs head) for me. It calls a gmap specific hook. Because there is no 'flexinode' module, I created one. And because the data type is "flexinode-1" I also translated the "-" to "_" before calling module_invoke(). This hook call allows a module author to control how their content will show up in a gmap bubble if the default is not good enough. It also allows flexinode content to be given a custom display. Similar code to this patch might also apply elsewhere in gmap_location.module. I didn't look beyond my immediate need with the node map display.

I hope you find this useful and incorporate it into the head and 4.7 branches. It extends the current gmap_location module and does not remove existing functionality.

138,148c138
<           // Allow a module (where the module name matches the node type name)
<           // to define a custom display for the google map label.
<           // For this to work with flexinode defined data types,
<           // a module called 'flexinode_#.module' in your site's module
<           // directory and add hook_gmapnodelabel($node) to it.
<           // Be sure to enable your 'flexinode_#.module'.
<           if($labelresult=module_invoke(strtr($n->type,'-','_'), 'gmapnodelabel', $n)) {
<              $newmarker['label'] = strtr($labelresult, "'\n\r", '"  ');
<           } else {
<              $newmarker['label'] = strtr(theme('node',$n,true),"'\n\r",'"  ');    //make sure it all goes on one line.
<           }
---
>           $newmarker['label'] = strtr(theme('node',$n,true),"'\n\r",'"  ');    //make sure it all goes on one line.

Comments

scott.mclewin’s picture

Sorry for the rapid fire patches. Use this one instead. It includes the location data on the hook callback.

138,148c138
<           // Allow a module (where the module name matches the node type name)
<           // to define a custom display for the google map label.
<           // For this to work with flexinode defined data types,
<           // a module called 'flexinode_#.module' in your site's module
<           // directory and add hook_gmapnodelabel($node, $location) to it.
<           // Be sure to enable your 'flexinode_#.module'.
<           if($labelresult=module_invoke(strtr($n->type,'-','_'), 'gmapnodelabel', $n, $locn)) {
<              $newmarker['label'] = strtr($labelresult, "'\n\r", '"  ');
<           } else {
<              $newmarker['label'] = strtr(theme('node',$n,true),"'\n\r",'"  ');    //make sure it all goes on one line.
<           }
---
>           $newmarker['label'] = strtr(theme('node',$n,true),"'\n\r",'"  ');    //make sure it all goes on one line.
webgeer’s picture

Status: Active » Fixed

Thanks for the patch,

I like this approach.

scott.mclewin’s picture

Cool. Thanks for incorporating the patch, and I'm glad the approch works for you.

Anonymous’s picture

Status: Fixed » Closed (fixed)