Quote:
Originally Posted by princessfrozen
Could this be modified to pull the zip codes (created by a custom field) from the database and generate the map based on that?
|
If you look at the code, there are "lookupZip" and "lookupAddress" methods. If you added a custom user field to store zip code, then you could certainly write a batch script to popuplate the map tables with markers.
The INSERT statement would look like this. I wrote a quick script (It's a total mess or I'd post it) that tries to do a lookup on the "location" field so as not to make the user enter a zip. Only about a hundred of our users put in resolvable locations, however.
The script would need to select all of the users from the DB...this statement grabs their location:
$userlocation = $db->query("
SELECT user.userid, user.username, user.usergroupid, opts.field2
FROM " . TABLE_PREFIX . "user AS user
LEFT JOIN ".TABLE_PREFIX."userfield as opts ON opts.userid = user.userid WHERE field2 IS NOT NULL");
Then loop through each one, call the lookupAddress method. If a latitued and longitude are returned do an insert like this:
$db->query_write("INSERT INTO " . TABLE_PREFIX . "googlemap (userid,username,usergroupid,text_map,lat_map,lng_ map) VALUES ('" . $loc['userid'] . "','" . $loc['username'] . "','" . $loc["usergroupid"] . "','" . $loc["username"]. " is in ".$l."!','" . $lat . "','" . $long . "')");