Looking for help to integrate GOOGLE MAPS+SMF **Demo available

Started by Ride, August 18, 2005, 01:49:21 PM

Previous topic - Next topic

PhatTyres

Hey Ride...
I like your integration...anything you can share with TLM, to get the avatars, additional Pins, members, and stuff you have on your maps.
And your members, do they place pins or call a zip code for general location.

I would like to add locations for trail heads, and an eventual trail database with trail descriptions, comments, maps, and Google Earth interation.
OTB and Runnin Down The Hill

SMF 1.0.5  MKp1.0                                Clip'd In Cycling Community

TLM

Quote from: PhatTyres on December 19, 2005, 08:44:32 PM
Hey Ride...
I like your integration...anything you can share with TLM, to get the avatars, additional Pins, members, and stuff you have on your maps.
And your members, do they place pins or call a zip code for general location.
Your saying I dont know how to add avatar, and things? :P  I just pushed the mod out early to appese people that kept posting wanting it.  Avatars and some permissions will be done tonight.

Quote from: PhatTyres on December 19, 2005, 08:44:32 PM
I would like to add locations for trail heads, and an eventual trail database with trail descriptions, comments, maps, and Google Earth interation.
Sounds like a whole new map idea there, but I am guessing that you would like it to be merged with the member map?

HoTmetal

I was thinking of a way to limit pins, and still have this mod usefull. Is there a way pull x number of users closest to location x. For example at Ride's site,  it could show the 1st 150 members closest to Bear Mountain. Of course the 150 is a number set in the admin panel, it could be more or less. Then the user could set location X based on their needs. I'm not sure if this is possible, & or the best way to go about it....
Just a thought

Good work thus far.

PhatTyres

QuoteYour saying I dont know how to add avatar, and things? Tongue  I just pushed the mod out early to appese people that kept posting wanting it.  Avatars and some permissions will be done tonight.

No...No...No... not doubting your skills I just liked his integration...and wondered if Ride could help out.

I appreciate your Push in the last few Days.
I understand that you wanted to put up what was already done and more is to come.

QuoteSounds like a whole new map idea there, but I am guessing that you would like it to be merged with the member map?

Yes I would like to merge data with the Member Map.

I am playing with the features but It is slow work for me...I am an absolute php,sql idiot.
OTB and Runnin Down The Hill

SMF 1.0.5  MKp1.0                                Clip'd In Cycling Community

TLM

Quote from: rickc on December 19, 2005, 09:09:40 PM
I was thinking of a way to limit pins, and still have this mod usefull. Is there a way pull x number of users closest to location x. For example at Ride's site,  it could show the 1st 150 members closest to Bear Mountain. Of course the 150 is a number set in the admin panel, it could be more or less. Then the user could set location X based on their needs. I'm not sure if this is possible, & or the best way to go about it....
Just a thought

Good work thus far.
Well if you wanna go about that way, X number closest to Y User.  This will work but I dont know how well/what kind of performance hit this will cause.  Use the good old distance formula, just think lat and long of both users is there x and y cordnats, then it just becomes sqrt((x1-x2)^2 + (y1-y2)^2) (if memory serves me right on the formula), and take your answers, make an array, sort the array on that number and take the first X or so, then from there cross back to the users table with the ids, vola.

Quote from: PhatTyres on December 19, 2005, 09:14:12 PM
QuoteYour saying I dont know how to add avatar, and things? :P  I just pushed the mod out early to appese people that kept posting wanting it.  Avatars and some permissions will be done tonight.

No...No...No... not doubting your skills I just liked his integration...and wondered if Ride could help out.

I appreciate your Push in the last few Days.
I understand that you wanted to put up what was already done and more is to come.
Well what he has done, I dont think I could use much more of, I might be "stealing" his member listing of users.  By "stealing" I mean looking at the code and seeing how he went about the list linking into the map causing the popup.  From a breif glance it looks fairly simple.

Quote from: PhatTyres on December 19, 2005, 09:14:12 PM
QuoteSounds like a whole new map idea there, but I am guessing that you would like it to be merged with the member map?

Yes I would like to merge data with the Member Map.

I am playing with the features but It is slow work for me...I am an absolute php,sql idiot.

I might much later on down the way, include perhaps a way for someone to include a xml file or something with points and paths...  dunno yet about that, talk to me much later on about this. :)

HoTmetal

Quote from: TLM on December 19, 2005, 09:15:18 PM
Quote from: rickc on December 19, 2005, 09:09:40 PM
I was thinking of a way to limit pins, and still have this mod usefull. Is there a way pull x number of users closest to location x. For example at Ride's site,  it could show the 1st 150 members closest to Bear Mountain. Of course the 150 is a number set in the admin panel, it could be more or less. Then the user could set location X based on their needs. I'm not sure if this is possible, & or the best way to go about it....
Just a thought

Good work thus far.
Well if you wanna go about that way, X number closest to Y User.  This will work but I dont know how well/what kind of performance hit this will cause.  Use the good old distance formula, just think lat and long of both users is there x and y cordnats, then it just becomes sqrt((x1-x2)^2 + (y1-y2)^2) (if memory serves me right on the formula), and take your answers, make an array, sort the array on that number and take the first X or so, then from there cross back to the users table with the ids, vola.

Ok, so it would work, thats good news, but is this a good way to handle things? I know I could use this, but there's no way I could code this... I'm lost after print "hello!"; lol I'm learning. I look  through the code & see how things work, but making things, thats another story.

TLM

Quote from: rickc on December 19, 2005, 09:19:52 PM
Ok, so it would work, thats good news, but is this a good way to handle things? I know I could use this, but there's no way I could code this... I'm lost after print "hello!"; lol I'm learning. I look  through the code & see how things work, but making things, thats another story.

Let me push out 0.50 of my mod then, I shall see what time it is, and if theres time, I shall write you some psudo code that might help you along the way.

HoTmetal

Quote from: TLM on December 19, 2005, 09:21:27 PM
Quote from: rickc on December 19, 2005, 09:19:52 PM
Ok, so it would work, thats good news, but is this a good way to handle things? I know I could use this, but there's no way I could code this... I'm lost after print "hello!"; lol I'm learning. I look  through the code & see how things work, but making things, thats another story.

Let me push out 0.50 of my mod then, I shall see what time it is, and if theres time, I shall write you some psudo code that might help you along the way.

Sweet !! Aaahhh psudo code, I might be able to put it to work.(depends on how much beer I have before hand) Baby steps.... I like it ....:D (thanks) But I don't want to waste your time, unless this could be a usfull thing for other people. I'm just happy that someone took the time to get this far. I will D/L your new ver. when it gets approved.... (Unlike last time I tried to D/L before hand :D) thanks again TLM ~~~

TLM

Well, it should be approved right now, just 0.50 is not done so its not up. :P

Looking at the avatar thing, oh boy thats gonna be fun, how did you go about doing the avatars yourself there rickc?  Did you query the attachments and members table hunting down avatars? Or is there some unknown function in smf I dont know about that pulls the members avatar?

HoTmetal

Quote from: TLM on December 19, 2005, 09:37:26 PM
Well, it should be approved right now, just 0.50 is not done so its not up. :P

Looking at the avatar thing, oh boy thats gonna be fun, how did you go about doing the avatars yourself there rickc?  Did you query the attachments and members table hunting down avatars? Or is there some unknown function in smf I dont know about that pulls the members avatar?
Actually. forsakenlad did my joomla integration.
Um, I could look at the code, but I'm not too sure on how he did it... I'll post the code here though , when I find it...

TLM

Thats ok, I think I found the function I am was looking for, now the trick is to understand the output, and if it works the way I think it does, it will further optmize part of my mod. :)

TLM

Well here is the code I used to pull the member data of who have lat/long, which also allowed me to pull avtar info and other nice things real easily if your interested.  It was a devil of a time tring to search on loadMemberData() and loadMemberContext() here at SMF, so I though I would throw this up incase anyone else needs it...


global $db_prefix, $memberContext;

$query = "SELECT *
FROM {$db_prefix}members
WHERE latitude IS NOT NULL AND longitude IS NOT NULL";
$request = db_query($query, __FILE__, __LINE__);

//Ok this is block of code takes care of the entire load all member data into $memberContext on per # basis
$temp = array();
while ($row = mysql_fetch_array($request, MYSQL_ASSOC))
   $temp[] = $row['ID_MEMBER'];
loadMemberData($temp);
foreach ($temp as $v)
   loadMemberContext($v);

print_r($memberContext);


With the above code here is your psudo/php code now... you might have to clean it up into proper php...

global $db_prefix, $memberContext;

//What point we working from to the users?
$point = array()
$point['latitude'] = 0;
$point['longitude'] = 0;

//Lets get the users...
$query = "SELECT *
FROM {$db_prefix}members
WHERE latitude IS NOT NULL AND longitude IS NOT NULL";
$request = db_query($query, __FILE__, __LINE__);

$temp = array();
while ($row = mysql_fetch_array($request, MYSQL_ASSOC))
   $temp[] = $row['ID_MEMBER'];
loadMemberData($temp);
foreach ($temp as $v)
   loadMemberContext($v);

//Calculation time...
$temp = array();
foreach ($memberContext as $member)
  $temp[$member['id']] = sqrt(pow(($point['latitude'] - $member['googleMap']['latitude']), 2) + pow(($point['longitude'] - $member['googleMap']['longitude']), 2));

natsort($temp);
//At this point we should now have a sorted list lowest to highest, along with member ids by $temp['id']
print_r($temp);


The reason I used $member['googleMap']['latitude/longitude'] was how I constructed it in my mod, so you can look at my mod and figure out how I got that, I do belive the above should do you.

Advertisement: