how to print google map field value in a page tpl I am trying to print a value of submitted for a google map field in a page.tpl.php file. I used below code to print but got a error message. I am able to print other field types using similar code but unable to do the same for map filed. Please help

&lt;?php
  $node=node_load(41);
  print "&lt;div id='map'&gt;".$node-&gt;field_add_map['und'][0]['GoogleMapField']."&lt;/div&gt;";// print styled image
?&gt;
For a start don't load the node in the template file like that.

If you want to load a node do it in a template preprocess function in your theme's template.php file, like this for example:

/**
 * Variable preprocess function for the page template.
 */
function THEMENAME_preprocess_page(&amp;$variables, $hook) {
  // Load a node and save it to the variables array.
  // This will then be available in the variable $node, in the page.tpl.php template.
  $variables['node'] = node_load(41);
}


However don't use $variables['node'] in the page template because it is already in use.
If you are on a node page then that variable will already be populated with the node object of the current page, so in your template you can access it using $node.

If you are aloading a node that isn't the current page node then you can do it your way but give the variable a different name, like $variables['map_node'] for example, which would then be available in the template file as $map_node.

On to the field printing.

The problem is you are trying to print the GoogleMapField property of the field value, which as far as I know doesn't exist.

The values in this field type are:


lat
lon
map_width
map_height
zoom
name


So doing what you are doing you could print those out, however I'm thinking you probably don't want those either.

So you want to print the rendered field item.
There are a few ways this can be done but a good option is using the field_view_field() function like this:

/**
 * Variable preprocess function for the page template.
 */
function THEMENAME_preprocess_page(&amp;$variables, $hook) {
  // Load a node and save it to the variables array.
  // This will then be available in the variable $node, in the page.tpl.php template.
  $variables['map_node'] = node_load(41);
  // Get the rendered markup for the map field to print in the template.
  $variables['rendered_map'] = field_view_field('node', $map_node, 'field_add_map', 'full');
}


That example uses whatever display configuration you have set on the "full" display mode for your node type for that field. You could use "teaser" or some other view mode if you prefer.
You could even add a custom view mode specifically for this if it suits your use case.

Then in your page template you could do something like this to print the map using the render() function:

if ($rendered_map) {
  print render($rendered_map);
}