Google Maps module

barneson - July 7, 2005 - 02:41

I've worked up a Google Maps module that interfaces with Drupal's built-in RSS functions and the locative data that is added to those RSS feeds by location.module.

http://choirgeek.com/gmap

It's a work in progress, and there is obviously room for much more functionality, including content filtering, usability improvements, plotting nodes from other RSS sources, etc....

Thanks in advance for your comments and suggestions.

-Bjorn

P.S.

barneson - July 7, 2005 - 02:42

This uses the new Google Maps API -- not one of the "unofficial" google map hacks.

--
Bjorn | choirgeek.com

Awsome!

robertDouglass - July 7, 2005 - 05:14

That looks really great. I can hardly wait to get my greedy hands on that code :-) Very fine contribution.

- Robert Douglass

-----
If this helped you, please take the time to rate the value of this post: http://rate.affero.net/robertDouglass/

www.hornroller.com, www.robshouse.net

When I get a chance to get

barneson - July 7, 2005 - 12:42

When I get a chance to get the coding cleaned up and properly commented, I'll post the code.

--
Bjorn | choirgeek.com

module code

barneson - July 14, 2005 - 04:14

Here is a rough draft of the googlemap.module: http://choirgeek.com/files/googlemap.module.txt. Download it, rename it to "googlemap.module" and drop it into your modules directory.

This module uses the locative output from the excellent location.module. I'm not sure that googlemap.module will work without location.module until it's possible to plot external RSS feeds.

Be sure to check permissions and settings. You'll need to get your own Google API key (free) to use for your domain. This module will not function without it.

I'm going to continue tweaking this module, so if you have improvements or suggestions, please post them here.

--
Bjorn | choirgeek.com

Wonderful. Why not keep it in the Drupal repository?

robertDouglass - July 14, 2005 - 07:52

I don't know if you've considered applying for a Drupal developer account for the CVS repository, but that would allow you to maintain it as a full Drupal module, including having it appear on the Downloads page. If that sounds like too much work I'm sure you could find someone who already has an account to put it in the repository for you.

- Robert Douglass

-----
If this helped you, please take the time to rate the value of this post: http://rate.affero.net/robertDouglass/

www.hornroller.com, www.robshouse.net

VERY GOOD MODULE. Please

Gunny - July 30, 2005 - 00:24

VERY GOOD MODULE. Please open a cvs account so that making fixes would be easier.

Now in CVS repository

barneson - August 17, 2005 - 23:52

My first time using CVS, but I think it worked.

http://cvs.drupal.org/viewcvs/drupal/contributions/modules/googlemap/

To be honest, I don't have a lot of time for further development right now, but I would welcome others picking up where I have left off.

FYI, the code I committed is the same that is working at http://choirgeek.com/gmap.

--
Bjorn | choirgeek.com

API limitations

Thox - July 14, 2005 - 08:29

Is the Google API still limited on a per-directory basis? If so, this would break when the user turns on/off clean URLs. It would also prevent you from having a URL like example.com/gmap/users.

Could the javascript be moved into a file of it's own? I don't like seeing big blocks of it on a page. Note: CVS has a new drupal_add_js() function.

I get javascript errors when using the map:

Error: item.getElementsByTagNameNS("http://www.w3.org/2003/01/geo/wgs84_pos#", "lat")[0] has no properties
Source File: http://choirgeek.com/gmap
Line:
65

I also don't see any points marked on the map, just the map itself.

With some tweaks and improvements it could be a popular module.

As of now, the module

barneson - July 14, 2005 - 18:56

As of now, the module doesn't work quite properly with IE. Something to do with parsing the locative namespaces in Drupal's RSS feeds, I think.

Re: the Google API key limitations, I think that the module will work with clean urls turned on or off.

http://choirgeek.com/gmap
http://choirgeek.com/?q=gmap

You are right in saying that the current version of the API will not allow for extra arguments, i.e. "gmap/users" or "gmap/concerts". However, there has been some rumor among the faithful that Google will ease those limitations in future versions of the API.

--
Bjorn | choirgeek.com

google maps - problems with IE, possible solution

ciaran.lee - July 20, 2005 - 13:24

I found this at: http://compooter.org/article/125/google-maps-and-hurricane-data

The only thing that had any effect was to ensure all JavaScript was no longer nested within divs (or tables if that’s what you’re using) and that it was located later in the document flow than the map-related container elements.

I dont have enough technical knowledge of drupal to know if it is possible to do this, but basically it looks like you need to have the javascript below every div on the page, including the footer.

Does anyone know if this is possible?

actually no...

ciaran.lee - July 20, 2005 - 13:31

Perhaps I should have checked that last one out before I posted it, It IS possible to have the javascript before the last div, as can be seen at
http://netsoc.tcd.ie/~leecn/SPE/static.html

XHTML Strict

gregmills - July 18, 2005 - 11:12

When I tried to set up a Google Map on my site I no problem with the key. I created it for http://www.site.com/node and it worked fine.

Well, it worked fine in Firefox. In IE the page won't load at all. I searched through the Google Group for the map api and discovered that in IE your page has be generated in XHTML strict and Drupal is in XHTML transitional. Has anyone else had any problems with an "Operation Aborted" error in IE?

XHTML Strict

ciaran.lee - July 19, 2005 - 23:25

Yeah, I have the same problem. I thought maybe I had messy javascript that IE didnt like (never used javascript before), but it could be that IE just wont read it unless the page is XHTML strict.

cool

moshe weitzman - July 20, 2005 - 02:58

i had to refresh for some reason to get the map ... i noticed a javascript error as well:

Error: item.getElementsByTagName("latitude")[0] has no properties
Source File: http://choirgeek.com/gmap
Line:
71

Another way

ckng - August 17, 2005 - 03:49

Here is another way to integrate Google Maps into Drupal
http://nice3z.homeip.net/googlemap

Great module!

Joshuwa - August 17, 2005 - 18:37

This module in combination with location.module make a lot of really cool things possible.

I'm not a programmer, but I would love to help out with this as much as possible.

One thing I'd like to see is the ability to have additional maps (ie include a map in any node). Other than that, I think this is one of the most interesting modules there are.

-----------------
Josh Stevens
Nautilus7 Design | Tibathon.com - Home of the National Tiburon Meet

Fixed the IE errors

sasquatch - August 26, 2005 - 22:27

The key is to enclose the map rendering JS in a function, ie LoadMap(), then call it from the body onload event; I used:

$content .= "function init(){\n";
$content .= "LoadMap();\n";
$content .= "}\n";
$content .= "window.onload=init;\n";

IE apparently runs the open JS script before the page html fully loads, thus the errors..

Yes! That's working:

pkreemer - September 30, 2005 - 23:56

Yes! That's working: http://sub-log.com/shipwreck_map

Kind of funny that you can set the body onload function while the page is loading but IE won't just process the original script. And I always thought that onLoad kicked off before the page was fully loaded...

Anyway, Google Maps are great fun, as is Drupal.

thanks-
Paul

sample code?

jasonwhat - February 21, 2006 - 07:55

Could you give a sample of how the correct code would look? Is this something that needs to be changed in the module or code placed in the template?

Also, is this module fully working for anyone? I'm having the xml parsing error as seen here, http://drupal.org/node/36493

 
 

Drupal is a registered trademark of Dries Buytaert.