Hi everyone.

http://cvs.drupal.org/viewcvs/drupal/contributions/sandbox/jpwillms/goog...

Sometimes location.module is a little bit overkill for some peoples needs. Here is an initial release of a google maps for nodes module. It essentially lets you tack on an address field, and the system will automatically lookup geocoding information for that address, and plot the point on a google map when the node is viewed.

Obviously, this is just the start of what could be an awesome module.

Suggestions I've already received:

- Be able to view larger maps of all nodes locations on a map
- The same as above, but filtered by taxonomy terms (so cool, and pretty easy to do).

Anyways. Enjoy! I'd also appretiate feedback and for someone to rip apart the code. (I programmed it in about 2 hours this afternoon).
You may want to also note that it currently only supports US addresses. This is because of the geocoder that is uses (geocoder.us), but you are free to change to any geocoder you want to use.

Cheers!

Thanks to DonatGroup.com and http://www.ProjectOpus.com for sponsoring me to write and donate this simple bit of code!

Jordan Willms
http://www.jordanwillms.com

Comments

boris mann’s picture

If you are serious about maintaining this on Drupal.org, you should move this to /modules/googlemapsfornodes. I created a placeholder project for you but left it in the moderation queue -- it's owned by you, so you should be able to edit it as desired.

And of course, I would hope that you accept patches that make it work with the location module if desired and/or re-uses the location table :P

jpwillms’s picture

Of course my man!

This code can be used to do whatever, etc.

Next week I'm adding Maps with markers per taxonomy term involved, and a global one. I think that will be quite helpful to everyone. All the spanning / zooming, etc will be done automatically.

I'll keep everyone updated.

..jay

sethcohn’s picture

Why would start this new module, when googlemap is already in CVS, and still needs improvement work, but is quite functional.

Googlemap module in CVS

That module lets you give it a RSS feed, and it plots the locations.

Can you merge your code with googlemap and provide one module with the features of both as options? That is, map both individual nodes OR map out RSS feeds (and since taxonomys and other 'lists' in drupal likely have an RSS feed option, them too)

boris mann’s picture

Actually, if you look at the code, Jordan's module is very different -- it provides maps *per node*, not one giant one with nodes mapped on to it.

Also, Googlemap module only works with RSS feeds, while Jordan's looks at the info from the node itself. We have the data in the Drupal database directly, why would we have to rely on an RSS feed, especially one generated by Drupal itself?

The googlemap module may as well be called rssgooglemap, since that's all it does (and I've never seen it working correctly, with data from a Drupal site, since you actually need lat/long values in your location.module to have it work).

Colin is going to extend it to tie into location module.

sethcohn’s picture

Boris, my point is that we don't need 2 different modules, when one module could do both...

googlemap pays attention to lat/long via the location module, this other module ignores location module (right now)

googlemap maps groups of nodes, this modules maps single nodes.

I want _one_ module to do google mapping, not 2 completely different chunks of code...

sepeck’s picture

I look forward to your patches then

-sp
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

sethcohn’s picture

When someone answers this one for me...
http://drupal.org/node/32067

The info I'm wanting to spider include addresses, and I want to map them in a variety of ways, so it's part and parcel of my plans anyway.

And, it also looks fairly trivial to merge the 2 right now...
Which is why I suggested it... I hate to see the wheel reinvented.

sepeck’s picture

If you can implement this as a patch against an existing module, then go ahead and add the patch as a feature against the existing project.

-sp
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

sethcohn’s picture

Part of this should be in location.module (the geocode part).
There is already a good start to geocode patching for location.module
here
and half this code should be dealt with there. The entire notion of storing lat and long in a new table should be scrapped - that is location's job and forte.

The mapping code should be added to the existing googlemap module, improving that module by making it do any sort of rss feed (more than just one), mapping single nodes, groups, or search results, etc...

As I said, I've got a project I can and will work on this as part of, but my first need is to import data, THEN to map it. I've got my priorities.

sethcohn’s picture

Correction: the patch linked above is already in the current 4.6.0 and head versions of location.module (and worth upgrading for, as it adds choice between Yahoo, Google and Mapquest for maps, and other improvements, including geocoding based on zips.)

bjornarneson’s picture

I am the developer of googlemap.module. I've got a start on integrating the code in googlemapsfornodes.module into my module, which already uses the locative data from location.module and doesn't require any additional database tables.

I'll commit my revised googlemap.module when I finish tweaking a few more things.

--
Bjorn | choirgeek.com

webgeer’s picture

I too have been working on a google map type module. This was intended for my own use. (the googlemaps module was not at all appropriate for what I wanted)

My version is simply to create a macro using interactive tool and then use a filter to insert the map based on the macro into a node.

I have it mostly working, but currently for some reason IE doesn't like it (works in Firefox) and there are some details and security issues to deal with in the node insertion filter.

For an idea of how my module works you can go to (with firefox):
http://vancouver.cyclehome.org/?q=gmapmacro

This shows the macro creation tool.

If anyone wants to integrate this project into one of these other ones, you are welcome to the code. My long term plan for this modules was to allow one to create overlays that would have for instance bicycle routes on the map. These would probably be stored in a database, but currently no database is required for this module.

webgeer’s picture

For anyone curious I fixed it so it works in IE. Even IE visitors can see this now: http://vancouver.cyclehome.org/?q=gmapmacro

(the fix was a really bad hack based on something suggested in http://andrew.sterling.hanenkamp.com/node/119 who interestingly is also using google maps in Drupal.

sethcohn’s picture

Another great tool.... the more options the better... looks like this could done as a inline filter combined with a popup (ala image assist)

Where can we download this? You posting it to drupal CVS?

webgeer’s picture

It isn't quite complete. The basics work, but some of the features don't yet work, there are a few more things I want to include, I want to come up with a more elegant solution to the IE bug, currently you have to hack the theme to include a few little things, and I think there may be some security issues with the current filter implementation. (I believe you could insert arbitrary javascript into the page using the filter). None of this is too difficult to fix, I'm just not sure when I'm going to have time to do it. Hopefully within the next couple of weeks, but I'm not sure...

I was going to wait until I got it all working before I CVS'ed, but if someone wants to take the code where it is now and finish it up or integrate it into their googlemaps project, I would be willing to share...

My initial thought was to do a image_assist type of pop-up, but I think there may be some problems with that and the google maps API need to be have a key tied to a specific webpage path (I haven't tested this yet, but from what I read I think this could be a problem -- I've thought of some alternate ways of achieving a similar type of thing, but these introduce more problems as well...)

Another idea I have had is that this macro creation can be done a little more behind the scenes and have it so the map generator could be used for custom nodes. For example business node that would then have a google map that you flag the location in and the macro would automatically be included in the custom node in the appropriate location.

I have also come across this project, http://bluweb.com/us/chouser/gmapez/ which is an interesting alternative.

wellsy’s picture

Your module is great! The macro tool seems to be precisely what I would like to setup for my site visitors to send me location or site admins to add information....excellent!

Will you be working on this to be compatible with 4.7 (cvs) and/or is it now compatible with 4.6.3

?wellsy
like someone else here said "always use a test site"
permit me to add "backup your database regularly"
orchidsonline.com.au

webgeer’s picture

I do not believe there is any problem with using this under 4.7. I will carefully go through again and make sure, but I don't believe any of the changes effect this module. (If they do I'll fix it).

wellsy’s picture

Although I have not installed this module on my site yet I think it sounds similar to what I am trying to do for my site at orchids online

I plan to locate orchid Species and Genus information on maps for site users based on information which I am hoping to store in the node OR in a new record in a table related to that node.

Can anyone point me in the best direction to move here?

wellsy’s picture

Quick update here

I installed the module on my drupal 4-6-3 site which is now live and public. I know.....always use a test site.....etc.

The database was modified using the mySQL file as instructed and after enabling the module I immediately found mySQL errors displayed at the top of the page plus the theme was destroyed for the site. I quickly disabled the module and all returned to normal.

Planning to run a test area now but I need another google map API key for that directory first. Asked google if that was OK but no reply from them yet...2 days ago. Does anyone know if google allows multiple API keys per user account?

sethcohn’s picture

they mostly want to track usage...

wellsy’s picture

Ok but when I setup a new directory key they will not revoke the old one will they?

Remember my other area - which is live - uses my first key.

Thanks!

wellsy
like someone else here said "always use a test site"
but permit me to add "backup your database regularly"
orchidsonline.com.au

larry’s picture

Hello all,

I think this module is great. It would be even better for me if I could make it work! I'm running everything correctly with drupal itself. Tested my googlemap API map key with google's test example in my directory...it works fine, so the map API key recognizes my test envirnment.

My problem is, when I try this on a node, I enter my location and it does not get saved. Even after previewing the node before submission, the location information is still there. It's only after I submit the node that the location information disappears. Has anyone else experienced this problem as well? Any suggestions?

thanks,
larry

--There are no Kangaroos in Austria--

larry’s picture

Really? I'm the only one having this problem? Any suggestions at all?

thanks,
larry

--There are no Kangaroos in Austria--

thinkinkless’s picture

I am having the same issue. Event is posted with the address, which never makes it into the db.
An additional bug happens upon editing the event, it says another user has already modified it.
Plus, cron fails. :(

I don't have suggestions for a fix (yet) but you're not the only one having problems with this module.

running 4.6.3/freetag

bensheldon’s picture

Wow, great module. I really like the node level map points. A couple things I would like to see:

* Support for lines
* Multiple points per node. 99% of the I think it should be only 1 point per node, but I'd like it for start and end-points.
* Ability to input raw lat/long data. I'm teaching a community mapping class with GPS and I want my students to do it the hard way. Also good for geocaching or out in the bush.
* You mentioned filtering by taxonomy, also filtering by user, and with different colored points.

Once again, awesome module.

nk126’s picture

This is awesome. Thanks & congrats on writing it.

I'm not much of a programmer but am able to tweak stuff other people have written -- i.e. I can install & customize modules, css sheets, etc with some success, but couldn't use the GoogleMaps API to make something from scratch on my own.

Anyway, I've insatlled your module, gotten it working, and played with it just a tiny bit to tweak the initial zoom level, to pass the title & body from a node to the map, and so on. So far so good.

I'm wondering ... Is there a way to keep a site-wide data file so that every time a node is created with a new map marker, the info gets dropped into that data file and that can be used to draw a site-wide googlemap?

In simpler terms, can I collect every node/address a user posts and use that collection to make a googlemap with every place anyone's ever created on my site?

Thanks again for this awesome contribution.

bensheldon’s picture

Checkout this post: http://drupal.org/node/39608
(I needed to get this in CVS 2 months ago)

It might not play friendly wih Google Maps For Nodes, but I'm looking into fixing that, 4.7 support, etc. Expect something good on that front in the next few weeks (and updated CVS).

vojnar’s picture