Advertisement:

Author Topic: Looking for help to integrate GOOGLE MAPS+SMF **Demo available  (Read 61265 times)

Offline Ride

  • Jr. Member
  • **
  • Posts: 185
  • Gender: Male
    • Southern California Snowboarding Forum
** EDIT 11/9/05   Almost all done.  Check it out on page 6 of this thread here: http://www.simplemachines.org/community/index.php?topic=46141.msg391988#msg391988



First off, for those that haven't seen it yet -----------> http://maps.google.com

Google maps has an api that allows developers to integrate with their own site/database/whatever    see -----> http://www.google.com/apis/maps/

I've made myself a simple little map (this is just for testing right now, eventually will have snow reports in info box).  It shows where local ski resorts are in socal.  When you click on a marker, you'll get info.  -------> http://www.ridesocal.com/map.html  (take a look at the source code to get an idea of how this simple example works)


Now what I'd like to do is integrate google maps with the smf.  I'd like to put a marker for every member on the map.  When the marker is clicked, it will show basic member info like avatar, membergroup, posts, etc.  To see an example of something similar, see the HotorNot+Google Maps integration here ---> http://hotmaps.frozenbear.com/


Google maps needs long/lat coordinates to set the market.  Of course it'd be silly to have members enter in their gps cords.  I think the best solution would be for users to enter in their zip code into the already existing location field in the profile.  I'm in the US so not sure how it works elsewhere for zip code type codes.  The zip code would then have to be queried to get the coresponding lat/lon cords and that info entered into the member's table in the database.  Free lists with zip codes and their lat/lon are available in a variety of places like here -----> *can't find the link right now
Also, I believe there are sites that allow you to query them with a zip and they return the coordinates.

An xml file could be generated with the member cords, info, etc. and then placed on the map with a marker.  How cool would this be?


I have experience with php, mysql, etc. but mostly from reverse engineering.  I see how bits and pieces work and am able to modify how things work w/o really know what makes them work.  This is where I turn to all the great people here.  As far as I know, no other forum software has done this yet.  It'd be great for smf to be the first!  Let's all put our heads together and make this happen!  Who's in?  ;)


Here are some google maps related links that may be helpful
http://www.map-server.com/googlemaps/wholocations2.php
http://dev.system7designs.com/
http://mapki.com/index.php?title=Knowledge_Base#Tutorials_and_HowTo.27s
« Last Edit: November 09, 2005, 10:27:47 PM by Ride »

Offline Slack

  • Jr. Member
  • **
  • Posts: 297
    • WeenieCampbell.com
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #1 on: August 18, 2005, 06:43:08 PM »
Royce I think this is a great idea and have been looking for something similar as I cannot get Member Map to run on my site anymore and  my users loved it.   I think in the long run an independent Map that reads the database is better than one that is an integrated Mod.  Not sure how much I can help -- I'm not reqally a prgrammer and have limited time - but I'll do what investiigating I can.

mapbuilder.net is very close the Location Mod (or SMF Member Map), you can place a pin on a shared Map by clciking a location, - but there seems to be a performance problem in showing more than 150 pins  -- have you checked this site out? 

Cheers,
slack

Offline Ride

  • Jr. Member
  • **
  • Posts: 185
  • Gender: Male
    • Southern California Snowboarding Forum
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #2 on: August 18, 2005, 07:40:10 PM »
Royce I think this is a great idea and have been looking for something similar as I cannot get Member Map to run on my site anymore and  my users loved it.   I think in the long run an independent Map that reads the database is better than one that is an integrated Mod.  Not sure how much I can help -- I'm not reqally a prgrammer and have limited time - but I'll do what investiigating I can.

mapbuilder.net is very close the Location Mod (or SMF Member Map), you can place a pin on a shared Map by clciking a location, - but there seems to be a performance problem in showing more than 150 pins  -- have you checked this site out? 

Cheers,
slack

Yeah, I haven't used their shared maps but I've used the service to use my own maps for my site.  I agree that it doesn't really have to be a mod, just able to read the db.  You would have to have at least a zip code in the db though.

Offline Ride

  • Jr. Member
  • **
  • Posts: 185
  • Gender: Male
    • Southern California Snowboarding Forum
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #3 on: August 23, 2005, 03:33:41 PM »
I'm curious to know what [unknown] thinks about this.

Offline Ride

  • Jr. Member
  • **
  • Posts: 185
  • Gender: Male
    • Southern California Snowboarding Forum
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #4 on: August 24, 2005, 09:20:15 PM »
You there unknown?   :P

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #5 on: August 25, 2005, 01:48:43 AM »
Google maps has an api that allows developers to integrate with their own site/database/whatever    see -----> http://www.google.com/apis/maps/

That's pretty cool.  If I had like... three of me, one of them might have time to play with that.

-[Unknown]

Offline Ride

  • Jr. Member
  • **
  • Posts: 185
  • Gender: Male
    • Southern California Snowboarding Forum
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #6 on: August 25, 2005, 02:16:27 AM »
Google maps has an api that allows developers to integrate with their own site/database/whatever    see -----> http://www.google.com/apis/maps/

That's pretty cool.  If I had like... three of me, one of them might have time to play with that.

-[Unknown]

Well, I'll work on cloning you soon.  Until then, maybe you can check back here for questions we may have?  I have an idea how to do it and might have some simple code questions.

Offline Ride

  • Jr. Member
  • **
  • Posts: 185
  • Gender: Male
    • Southern California Snowboarding Forum
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #7 on: August 25, 2005, 09:13:59 PM »
alright need just a little help.  I have in the database a list of zip codes and their lon/lat like this:

zip      |lat           | long          |

92835|33.90320|-117.91200 |


I changed the "location" field already in smf to "zip" and shortened the input box to only allow 5 characters.

What would be the best way to match the member's inputted zip code with the zip code in the db that has the lat/lon and put it into the smf_members table?

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #8 on: August 26, 2005, 12:12:12 AM »
Well, if you're getting just one member, with a query after knowing their zip:

SELECT lat, long
FROM geographic
WHERE zip = '12345'
LIMIT 1;

For multiple members, based on ID:

SELECT mem.ID_MEMBER, g.lat, g.long
FROM geographic AS g, smf_members AS mem
WHERE g.zip = mem.location;

Or similar.

-[Unknown]

Offline Ride

  • Jr. Member
  • **
  • Posts: 185
  • Gender: Male
    • Southern California Snowboarding Forum
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #9 on: August 26, 2005, 12:51:10 AM »
ok, that helps indeed.  I'm thinking the best way to do this is when they update their profile with the zip.  Would I just need to edit profile.template.php or profile.php?  (I'm digging around right now but thought I'd just ask anyways).

Would you mind posting the code as it would need to be inside profile.php or template.profile.php?  Thanks [unknown], I think I may be able to get this going tonight!!  (or today depending on where you are)

Offline Ride

  • Jr. Member
  • **
  • Posts: 185
  • Gender: Male
    • Southern California Snowboarding Forum
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #10 on: August 26, 2005, 05:13:33 AM »
I can't figure out where I put this   :(    Can anyone chime in?

Offline Tony Reid

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,154
  • Gender: Male
    • @AbsoluteBreeze on Twitter
    • www.fertilityfriends.co.uk
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #11 on: August 26, 2005, 05:34:09 AM »
This has got me all excited again :)

Here is a link to a page with a zip file of UK postcodes with  long/lat conversion..

http://www.easypeasy.com/guides/article.php?id=64

It uses the first half of the post code - so probably good for member privacy too.

US Version from 2001
http://www.cfdynamics.com/cfdynamics/zipbase/index.cfm
« Last Edit: August 26, 2005, 06:23:12 AM by Tony »
Tony Reid


My Big Board
www.FertilityFriends.co.uk/forum - An SMF powered forum with over 5 million posts

Offline Ride

  • Jr. Member
  • **
  • Posts: 185
  • Gender: Male
    • Southern California Snowboarding Forum
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #12 on: August 26, 2005, 01:19:22 PM »
I've already got those files for the us.  After I get it working I'll work on the uk too.

Offline Ride

  • Jr. Member
  • **
  • Posts: 185
  • Gender: Male
    • Southern California Snowboarding Forum
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #13 on: August 28, 2005, 09:21:04 PM »
The US zips as far as coordinates go are waaaaaay off.  The city matches the zip though so that's good.  I can add that to my other file so I have accurate city and gps cords for the zip.  Thanks!

So [unknown], can you answer my previous question?  I'm kind of stuck right now.  Also, once I have the cords in the member's profile, how would I out put every member's cords into a page (if the cords exist)?  Basically the outputed page will look like this:

javacript stuff bla bla bla var= $lat
bla blajbkalb albj= $lon
kadsjf sdf membername= $membername

javacript stuff bla bla bla var= $lat
bla blajbkalb albj= $lon
kadsjf sdf membername= $membername

javacript stuff bla bla bla var= $lat
bla blajbkalb albj= $lon
kadsjf sdf membername= $membername


Gracias!

Offline Tony Reid

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,154
  • Gender: Male
    • @AbsoluteBreeze on Twitter
    • www.fertilityfriends.co.uk
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #14 on: August 30, 2005, 07:33:22 AM »
This might help...

http://www.map-server.com/googlemaps/tutorial_writing.html

Obviously you will need to rip the post/zip code from the users profile.

Good luck

Tony

Tony Reid


My Big Board
www.FertilityFriends.co.uk/forum - An SMF powered forum with over 5 million posts

Offline Tony Reid

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,154
  • Gender: Male
    • @AbsoluteBreeze on Twitter
    • www.fertilityfriends.co.uk
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #15 on: August 30, 2005, 10:11:59 AM »
Hey Ride,

Ive started on a uk version - in fact very nearly there!  - although Im now wondering if its viable on large forums.

Tony

Tony Reid


My Big Board
www.FertilityFriends.co.uk/forum - An SMF powered forum with over 5 million posts

Offline Tony Reid

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,154
  • Gender: Male
    • @AbsoluteBreeze on Twitter
    • www.fertilityfriends.co.uk
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #16 on: August 30, 2005, 05:00:41 PM »
Nearly Nailed... I've got it working inside SMF's templating system... well its displaying a map - no pins... but thts where I need help :)

I have a table called geographic....

`id` int(11) NOT NULL auto_increment,
  `lat` decimal(10,6) NOT NULL default '0.000000',
  `lon` decimal(10,6) NOT NULL default '0.000000',
  `zip` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`id`)

id   lat                   lon                  zip
1    57.135000      -2.117000      AB10
2    57.101000      -2.111000      AB12

And So on.....

In my profile.template.php I have added the following....

Code: [Select]
', !empty($context['member']['options']['profile_post_code']) ? '</tr><tr>
<td><b>Zip: </b></td>
<td>' . $context['member']['options']['profile_post_code'] . '</td>' : '', '

From my understanding the profile_post_code is in the themes table.... hmmm thats where I am stuck.

My sql knowledge is not very good - but Im trying :)

Because I am doing a loop through the DB (which seems very slow - 25 seconds per page refresh) I chose to use your sql statement above to play with...

Code: [Select]
SELECT mem.ID_MEMBER, g.lat, g.lon
FROM geographic AS g, members AS mem
WHERE g.zip = mem.location;

From what I understand from the statement above - is that its pulling the location field off the profile(members table)

How can I redirect this to the profile_post_code from the themes table?

As I have thousands of members - would it not make sense to add this one field to the members table instead of the themes table? and if so - how do I do it?

Thanks for any help anyone can offer.

Tony,







Tony Reid


My Big Board
www.FertilityFriends.co.uk/forum - An SMF powered forum with over 5 million posts

Offline Ride

  • Jr. Member
  • **
  • Posts: 185
  • Gender: Male
    • Southern California Snowboarding Forum
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #17 on: August 30, 2005, 06:09:16 PM »
I guess you made a custom field for zip?  I just changed the "location" field to "zip" so that it stayed in the members table.  Maybe do that?

Offline Tony Reid

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,154
  • Gender: Male
    • @AbsoluteBreeze on Twitter
    • www.fertilityfriends.co.uk
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #18 on: August 30, 2005, 06:13:43 PM »
I thought about that - perhaps thats the best way to handle it on a single install - although my members have used it for location name so I have thousands of entries to remove :(

When(and if we get it working) this becomes a mod - it will need to have a solution that doesnt interfere with location though :(

Im still thinking that it needs to be an additional field on the members table.


Tony Reid


My Big Board
www.FertilityFriends.co.uk/forum - An SMF powered forum with over 5 million posts

Offline Ride

  • Jr. Member
  • **
  • Posts: 185
  • Gender: Male
    • Southern California Snowboarding Forum
Re: Looking for help to integrate GOOGLE MAPS+SMF
« Reply #19 on: August 30, 2005, 06:20:28 PM »
I thought about that - perhaps thats the best way to handle it on a single install - although my members have used it for location name so I have thousands of entries to remove :(

When(and if we get it working) this becomes a mod - it will need to have a solution that doesnt interfere with location though :(

Im still thinking that it needs to be an additional field on the members table.




Does this topic help?  Funny enough, it's about adding a zipcode field.

http://www.simplemachines.org/community/index.php?topic=37311.0