mapthing

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
drob's picture

Hi folks,

You might be interested in checking out mapthing. It is a simple module for creating google maps and mapping data points on them. I've abstracted out the data interface and there is a "plug-in" for CiviCRM data (please note that right now the CiviCRM module references are hard coded :( ). I got inspiration (and code :) ) from webgeer's cool GMap module. It's in contribs. Comments welcome.

Comments

Why not re-use gmap?

Boris Mann's picture

Anyway you could refactor and make it work with gmap, rather than duplicate code? I beleive webgeer means for it to be generally used, and he seems to have figured out the google map interface quite nicely.

of course

drob's picture

Yup. That would be perfect. I did spend some time with gmap and communicated with webgeer - here's the upshot:

  • gmap is in flux - 2 weeks ago there was a lot of work being done on it
  • i am not sure about all the data in the macro - don't know why this wouldn't be in a table
  • I was a little unclear on the data interface issues - but this could have been me
  • gmap is trying to be a wrapper around *all* of the cool features in the google maps API - nice, but lightweight is good too

So I wrote this - a good exercise for me and now we have something concrete to discuss instead of a lot of talking on lists :). That being said I'm very happy to merge, rip, mix and burn - no ego here. Best thing would be for folks to look at what I've done and start the dialog. I'm a strong believer in re-use and cooperation.

GMap

webgeer's picture

I took a look at your module, and I think it is a neat idea. I really encourage you to switch it to use the gmap.module's api.

I'll respond to some of your specific comments:

  • There has been some work on the module lately, but other than renaming some of the functions the programming API has been quite stable for a while. Although I do expect to make some changes to the API (splitting apart lat/long is the big one), I expect the function to stay entirely backwards compatible so anything designed for the existing function should continue to work.

  • This is obviously just a different approach for storing the information for the map to be inserted by the filter. For what I wanted the approach of using a macro made a lot of sense. However, I can envision other cases where storing the map information in a table associated with a node makes a lot of sense. That is why I encourage you to switch to the gmap API. That will allow users the option of which filter to use depending on their preferences. The macro then also allowed a convenient short-hand to be used in other places where users needed to enter the definition for a map.

  • I have now included a little bit more documentation on the gmap variable which defines all of the information for the google map, and is used by gmap_draw_map() to draw the map within the module. Hopefully, this clears up any confusion. Feel free to e-mail me and I can give you some additional insight if necessary.

  • the gmap.module is not that heavy of a module and any features that are not used are skipped. I think compatibility is more important than trying to keep the size of the module too small.

I think all you would have to do to have this module use the gmap API is to change your createmap function so rather than creating the javascript to draw the map, it builds a gmap variable and then calls gmap_draw_map() function.

I think it is important to get a single API for creating google maps as I think that having different modules do it in different ways will create a lot of incompatibility between the modules. It will also create a lot more head-aches whenever google changes their API in that each module would need to be updated. By having one module handle all of the js creation for drawing the map, this will be minimized.

James
(Webgeer)

I'm pretty much there

drob's picture

I'm happy to switch if it makes sense - and it sounds like there is a lot of reasons to. One thing I'm really not sure about are these huge macros with all that map info. Couldn't we just abstract that out? I need to look at your code more closely and I'll consult via email and perhaps IRC if you are there. I'm looking forward to collaborating.

gmap associative array

webgeer's picture

You wouldn't use the macro, you would use the gmap variable, which is an associative array. See the second half of API.txt for a more detailed description.

I should also say that if you want to add a few switches for your preferred use in the associative array, I'm quite willing to accomodate. For examble I noticed that your createmap function does not create the <div> for the map itself, whereas my gmap_draw_map function does create the <div>. If you think this is a better way to do it for your usage, then I don't mind adding a switch so that if you set mapvar['nodiv']=true, it doesn't write the <div> for the map.

James

all good

drob's picture

I really need to spend time looking more closely at gmap - I appreciate your interest in having a single api - and I share that. I'm sure that I can leverage your stuff. I won't have time to really look at this for a couple of days, but then I'm sure I'll have questions. Thanks for all your help (and getting me going in the first place :) ).

Dan

jumpin into the geo spatial world with two feet

bobk's picture

Hi Dan...

I need to catch up on what has been done already to avoid reinventing the wheel.

My interest is in catching events within a geo spatial interface. I've tried w/ google earth, but they don't really support
any specific on (XXX - fill in the blank) events. seems like just a on time-cycle, and on stop the world, kinds of things.

I need to be able to edit based on geo info, and have a mouse click automatically fill in a form w/ long/lat values.

Is this possible with either of these widgets?

thx...

i think so

drob's picture

Bob,

I'm not sure exactly what you want to do... The google map api is event based javascript. You have a lot of control over what happens in the map area. I use it two way - changes to the edit form change the map and when the use moves, zooms etc. on the map the form is updated. Does that answer your question?

Dan

gmap.module and location.module

webgeer's picture

If I understand what you want correctly, by installing location.module and gmap.module you can achieve that.

If you set it up so that location.module is enabled for your event nodes and make sure that users that enter events have access in location.module to set lat/long, then when they set the location of a node a google map will appear above the lat/long fields and when you click on the map the map will fill in the lat/long fields, add a marker and zoom in for you to more precisely set it.

If you just wanted to have a widget to edit your own lat/long fields you can use the gmap.modules function call gmap_set_location($map_macro,&$lonform,&$latform), where $map_macro is the a gmap macro defining the base starting map (which can be a blank string to use the default gmap map), lonform and latform are drupal form arrays for the latitude and longitude text entries. It will return the text to draw the map complete with the necessary js for this function to work. You can look at the location.inc for an idea of how to implement it.

Both this and the next reply

bobk's picture

Both this and the next reply seem to answer my question.

I want to be able to create an editor that allows me to click on a location and then tag it seperately, so that I'm not tied to the interface, and the actual dataset/database of long/lat based info is portable.

The only thing I would be missing if I want to apply the db to a google earth context is altitude and tilt, but I guess I can set defaults and allow the editor to adjust.

Mapthing map node, just what I am looking for!

Summitnl's picture

Hi,

I came on this thread by coincedence. I can only see mapthing in cvs. Is it Drupal 5 compatible?
If not can it become drupal 5 compatible?

Thanks in advance for your reply!
Greetings,
Martijn

mapthing

scorpio125's picture

I would like to use mapthing and try it out . I too want to know if it is available in Drupal 5.x.x

Location and Mapping

Group organizers

Group categories

Wiki type

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week