Hello!

I installed and enabled the location and gmap modules. This creates a node called map/node which is a node that should display the locations of the nodes (but I can't get it too work):

http://www.whatsonchiangmai.com/map/node

I have used the macro function to create a default map over my city, but when I click on the node it comes up as the original default (in the wrong side of the world!).

Also, I have looked all over the admin panel and I can't find where to assign long / lat to a node so it will show up on map/node above.

Please help!

Thanks so much!

Comments

H3rnand3z’s picture

This http://zacker.org/screencast-drupal-mashup-machine helped me set up gmap and location module. Although it is for drupal 4.7 there is enough information there to make GMap work in drupal 5.x

cherryh’s picture

I watched this video. I have a question, how did he generate longtitude and latitude for so many records? Is there any tool which can generate longtitude and latitude by using addresses?

Thanks.

4wding’s picture

Sorry, I don't use the location module, but have extensive experience in using gmap if you need any help there, just let me know.

Check out my use of gmap here:

http://www.hikeoz.com

neo_silkroad’s picture

Hi wding!

I have the basic node map up at this location:

http://www.whatsonchiangmai.com/map/node

What I want to do next is to add a long/lat field when I edit nodes, so each node will have an associated long/lat, and then I want to show them on at map/node

Thanks for your help!

geoffff’s picture

4wding, how did you use the Gmap module without Location? From what I can see it seems to require it. Did you have to modify the SQL queries in Gmap's code?

(EDIT: Never mind... I understand now how to use views & CCK instead of the stock /map/node Gmap page that uses Location.)

pbarnett’s picture

Hi!

I looked at the location module, and realised that it only works properly if you're in the US.

As for inserting Gmap macros into nodes, the lat/long information is in the macro, so you don't have to assign it to a node, providing that the input format for that node type has the GMap filter enabled.

If you do want to specifically assign a lat/long to a node type, you'd need to use CCK.

Pete.

neo_silkroad’s picture

Hi Pete!

Yes, it seems there are a few features missing from gmap and location; the more I look at this.

For example, the main point of Drupal are nodes, in a manner of speaking, but there is no way, without more customization, to even attribute location information to a node and associate a node to location. This seems odd to me.

But, if you look at Views, you can filter on Location, such as Location:Longitude and Location:Latitude , but how to associate these fields with a node requires CCK?

I get the feeling at Google Map support for Drupal is really quite immature; so perhaps I what I thought was "basic, simply gmap integration" is not "not supported"... ?

tostinni’s picture

Once location activated, you should go into admin/content/types then for each content type, edit it and activate the "locative information" section by putting at least 1 "default number of location" for this content type.
Then configure location module at "admin/settings/location", hide country selection and check "Use a Google Map to set latitude and longitude".
Configure GMap module "admin/settings/gmap" by putting your key.

Go create a content a you'll see the google map appears and 2 fields lat/lon.

Good luck, it's still a little tricky but full of promises.

4wding’s picture

One thing that frustrated me with the gmap module was the need to keep setting the api key each time I moved my site between different hosts. I have a number of different places I do development, on my laptop, home computer, work computer and my live site. So rather than go into the admin pages and set the key each time, I wrote a bit of php code to do it automatically, and this saves heaps of time.

In page.tpl.php I add this line to the top:

variable_set('googlemap_api_key', hikeoz_get_api_key());

And in my template.php file, I define the hikeoz_get_api_key() function as:

function hikeoz_get_api_key() {
  $host = $_SERVER['HTTP_HOST'];

  if ($host == '10.102.150.49')
    $api_key = 'ABQIAAAAtQo-WeDRQaBJD82Tco-LARTDrfZEvLLC4CLJybOk9cKftBAcLRSEXHot4j5Fj89pgmJ-vPcI11movw';

  if ($host == '10.1.1.214')
    $api_key = 'ABQIAAAAtQo-WeDRQaBJD82Tco-LARS-zKiKPc6PXEwbs6j3hV2IcDInzxQ7unoqoUHNbqU3pU1_USmM21E0Nw';

  if ($host == '10.102.150.41')
    $api_key = 'ABQIAAAAtQo-WeDRQaBJD82Tco-LARTjPfeRgbiUuh3PPeAJuMmQILeE3RR_aTcG_kmqfM9iAV-R3a4xsKgkZQ';

  if ($host == 'www.hikeoz.com')
    $api_key = 'ABQIAAAAtQo-WeDRQaBJD82Tco-LARQty1jKjZV83ogIgdL1JliAMpPN5RRYwejqquVLZU7iXQYrhG1epFd3RQ';

  return $api_key;
}

Of course you put your own key values in this function.

neo_silkroad’s picture

Hi Tostinni!

THANK YOU!

That cleared up two problems! Yes, I can add location info to nodes now (after enabling it in content types) and yes. the block now appears because the block is associated with the node.

Very cool.

You were right, tricky.... but it works now thanks to the help in this thread. I hope others in a similar situation find this thread useful.

Maybe I should summarize the steps for others?

neo_silkroad’s picture

Hi,

OBTW, my friend working on www.whatsonchiangmai.com did not like the fact that all nodes that used the location module had to have "Locations(s)" printed in the node content.

So, as a quick fix, I commented out a section of code, not to intelligently:

function theme_locations($locations = array(), $hide = array()) {
/** 
  $output = '<h3>'. t('Location(s)') .'</h3>';
  foreach ($locations as $location) {
    $output .= theme('location', $location, $hide);
  }

  return $output;
**/
}

Does anyone know where the function above is called, so I can stop this function before it is called. (I could not find it, for some reason!)

Thanks!

MahjongDirectory’s picture

Hi

neo_silkroad’s picture

Override is better... got it, I think!

I just realized that it is better to override the function theme_location() than to comment it out, so I did by creating a function in template.php ....

Sorry for the "non drupal" mistake of suggestion to comment out code .... I am slowing beginning to understand.

Maybe I'll learn more since John and Matt's book, Pro Drupal Development, arrived today!!

Yea!

4wding’s picture

It is a long process learning the details of using drupal, but very well worth. And the only way to learn is to get in there are write stuff for it, whether it is the correct or incorrect way of doing it, it means you are learning how pieces fit together.

You are right, providing an override of the theme_location() method would be one way to remove that information. In general, you should never modify existing drupal, or module code, anything that may need changes should be accessible from an override.

demo9’s picture

Hi neo_silkroad,

I was stuck on this very same issue today... (trying to get google maps to display with pages/stories - nodes), but had not read the whole thread... then I came across the Location(s) problem too. Anyway, it took a while but I figured out that the "Location(s)" option can be turned off on the page: admin/settings/location (duh!) part way down the page there is a heading "Toggle Location Display". simply select 'disable' and save... done!

Hope this helps someone else out there.....

neo_silkroad’s picture

Thanks demo9,

You are right. No need to override the function, it seems.

jeefers’s picture

I have on the blog article, when it displays a link "see google maps" that routes to google.com maps section and displays by the street address and not that lat and long. Is there any way to fix this??

Thanks,

jbjaaz’s picture

I'm not sure if I should of started a new post for this.

Anywho, I need to attach location information to some nodes and on a separate page display a giant google map with all the nodes displayed on it.

I really don't like location.modules UI. Do I need to use it with GMap?

My plan was just to add street, city, state, zip and country as cck fields and run with that. How difficult is it to roll your own module connecting custom cck fields with GMap?

I appreciate the feedback.

~John

scedwar’s picture

This is a simple node map:

http://www.charityrallies.org/en/map/node

--
Charity Rallies http://www.charityrallies.org
organised by UK charity Go Help: http://www.gohelp.org.uk/

summit’s picture

Hi,

Does anybody know how to get the Map displayed under Location(s). And not as a link to google maps?
I would like to show my users the map on the site itself.

See for a test of the not-wanted behaviour: http://www.isnow.in/test

Instead of the links to: Google Maps, Yahoo! Maps, MapQuest I would like to show the map itself as shown in the gmap macro after filling it in.

Thanks in advance!

greetings,
Martijn

pbarnett’s picture

...but the controls are missing; the page source says

/* <![CDATA[ */
Drupal.extend({ settings: { "gmap": { "block0": { "width": "100%", "height": "200px", "zoom": 10, "controltype": "None", "align": "None", "maptype": "Map", "line_colors": [ "#00cc00", "#ff0000", "#0000ff" ], "behavior": { "autozoom,+notype": true, "autozoom": true, "notype": true }, "markermode": "2", "id": "block0", "overlay": null, "markers": [ { "latitude": "40.723260", "longitude": "-73.988430", "markername": "drupal" } ], "querypath": "http://www.isnow.in/map/query", "longitude": "4.7296142578125", "latitude": "52.60971939156648" } } } });
/* ]]> */

i.e. "controltype" is "None".

Is this intentional?

Pete.

summit’s picture

Hi,

The block with the map under the Locations was the Locations block which showed the user-profile inserted map and not the node-map. I have removed it to be more clear on the problem of the page.

On www.isnow.in/test I can see the Location(s) text and hyperlinks to the google map.
What I would like is the behaviour that the map itself, and not the hyperlink to the map is shown.
Is this possible?
Please help.

Thanks in advance,
greetings,
Martijn

summit’s picture

Hi,

thanks to http://drupal.org/node/181340 I got it working.
My solution on http://drupal.org/node/191926#comment-633438

Greetings,
Martijn

mrgoltra’s picture

subscribing

socialnicheguru’s picture

subscribing

http://SocialNicheGuru.com
Delivering inSITE(TM), we empower you to deliver the right product and the right message to the right NICHE at the right time across all product, marketing, and sales channels.