Hi

At the moment I am trying to integrate the gmap in to my site but have a problem that I can't fix.
The problem is that I want the map with the position shown if you look at the node where the gmap is integrated.
I first tried to add a block. This seems to work but gave the problem that it was shift down when comments where added.
did't like that one.

So I searched through all the Issues here and found a way to integrated it in the node it self.
so I changed the node.tpl.php

and add the following code

    <?php 
      if ( $node->type == 'gop')
      {
        $homes=array('id' => 'outfittermap',
             'zoom' => 12,
             'width' => '640px',
             'height' => '480px',
             'type' => 'Map',
             'latitude' => $location['latitude'],
             'longitude'=> $location['longitude'],
             'markers' =>
               array( array('markername' => '$title',
                     'latitude' => $location['latitude'],
                     'longitude' => $location['longitude']
               ))
        );
        $outfittermap = theme('gmap', array('#settings' => $homes));
        print $outfittermap;
      }
    ?>

after the print $content .
Look at the result and it seems to work.
That was, until I looked at the Node locations window and clicked on one of the nodes.
google map opens a window to show the location content and tries to put a map in that window again because it is using
the node.tpl.php template.

so where did I go wrong ?
- Is the insert in the node.tpl.php the right way ?
- what variable can I use to stop the map from being displayed in the map?
- Do I need to add the map to the node in a different way ?

Amigob,

Comments

amigob’s picture

solved the problem my self. I found that the teaser was displayed in the pop-up and then looked in the
node code to find the variable that switched the teaser on and off.

no the If looks like this and the map isn't displayed any more in the pop-up

      if ( ($node->type == 'gop') && ($teaser != 1) )
      {
         .........

AmigoB,

summit’s picture

Hi,

This snippet helped me a lot!
Is there also a gmap variable which I can use in node.tpl.php? to set with the if...
Now the snippet is also run in my situation because I use the normal content types with localize (location.module) added.

greetings,
Martijn

scottrigby’s picture

Hi amigob,

Do you have any advice for me?

In my case, I'm using two maps.

- One is a page that lists all "Restaurants" (a custom content-type I made). The restaurants use the location module for the locative fields, Gmap for the map, and Views (Gmap View) to display the map itself. This map works ok (though I'd love to theme it more easily, it works).

- The second map I'm adding to the bottom of each Restaurant page. I'm using Location map, and adding the "Location map" block to "Content" in Admin > Blocks.
This is why I'm adding my comment here - I'm unhappy with how this displays below links, comments, etc. You seemed to find a way add your map to your node-type.tpl.php page. I'm also using a custom tpl page, but I think the details of the map I want are different from yours. Is there a way to help me understand how to modify the code above to show my (different) map on my custom node as you have?

Thanks in advance!
Scott

socialnicheguru’s picture

subscribing

computer_jin’s picture

I use this code in hook_view and i got an error message "GMap does not support multiplexing maps onto one MapID! "

   $homes=array('id' => 'outfittermap',
             'zoom' => 15,
             'behavior' => 'autozoom',
             'width' => '350px',
             'height' => '300px',
             'maptype' => 'Map',
             'latitude' => $node->location[latitude],
             'longitude'=> $node->location[longitude],
			 'markers' =>
               array( array('markername' => 'blue',
                     'latitude' => $node->location[latitude],
                     'longitude' => $node->location[longitude]
               ))
        );

        $outfittermap = theme('gmap', array('#settings' => $homes));

Any idea how to solve this ?

jindustry’s picture

A different way to address this problem is to give your node template access to the region with the map block. Normally, regions are only available in the page template. Follow this tutorial to make the region available in a node template: http://www.zyxware.com/articles/1188/how-to-create-custom-regions-in-nod....

fugazi’s picture

I've added code Drupal 6, it works beautifully.

<?php
   if ( ($node->type == 'page') || ($node->type == 'shop_guide' ) && ($teaser != 1) )
    {       
        $points = array(
            'id' => 'map'.$node->field_shop_adresse[0]['lid'],
            'width' => '100%',
            'height' => '300px',
            'latitude' => $node->field_shop_adresse[0]['latitude'],
            'longitude'=> $node->field_shop_adresse[0]['longitude'],
            'zoom' => 15,
            'maptype' => 'Satellite',
            'markers' => array(array(
                'markername' => 'big red',
                'text'=> $node->title,
                'markermode'=> 1,
                'opts'=> array('title'=> $node->title),
                    'latitude' => $node->field_shop_adresse[0]['latitude'],
                    'longitude' => $node->field_shop_adresse[0]['longitude'],
                )),
            );
            print theme('gmap', array('#settings' => $points));
	}
?>

How can I hide map when fields are not filled.

I've tested but it does not work.

if ( ($node->field_shop_adresse[0]['lid']) && ($node->field_shop_adresse[0]['latitude']) && ($node->field_shop_adresse[0]['longitude']) )
    {

Does anyone have a tip. Many Thanks

podarok’s picture

Status: Active » Closed (won't fix)

release unsupported
feel free to open issue against latest 7.x dev