Example #1
0
<?php

ini_set('display_errors', 'On');
error_reporting(E_ALL);
require 'header.php';
require_once 'fb-phpsdk/facebook.php';
//include our class
require_once dirname(__FILE__) . '/googleGeodecoder/class.googleGeodecoder.php';
//init our object
$geoDeco = new googleGeodecoder();
?>

<!DOCTYPE html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
  <title>FriendzOnMap</title>
  <link rel="stylesheet" href="media/css/style.css" type="text/css" media=screen/>
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  <style type="text/css">
/*      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }*/
      #map_canvas { height: 100%; width:1000px; margin-left:200px}
    </style>

  <!-- Script to import the Google Maps JavaScript API v3  -->
  <script type="text/javascript"
      src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDna6nDToZjaBoC7LkVr2WvVjnZWv388hs&sensor=false">
  </script>
  
  <!-- Importing the Jquery library  -->
  <script type="text/javascript"
Example #2
0
ini_set('display_errors', 'On');
error_reporting(E_ALL);
//include our class
require 'header.php';
require_once dirname(__FILE__) . '/googleGeodecoder/class.googleGeodecoder.php';
require_once 'googleGeodecoder/handleDB.php';
// if (isset($_POST['id']) && !empty($_POST['id']) && isset($_POST['name']) && !empty($_POST['name'])){
// 	$location['id'] = $_POST['id'];
// 	$location['name'] = $_POST['name'];
// 	getLatLng($location);
// }
//getLatLng();
//function getLatLng(){
//init our object
$obj = new googleGeodecoder();
//get the friend location
$fql = 'SELECT uid,name,pic_square,profile_url,current_location FROM user where uid in (select uid2 from friend WHERE uid1=me())';
//$fql = "SELECT uid2 FROM friend WHERE uid1=me()";
$friend_location = $facebook->api(array('method' => 'fql.query', 'query' => $fql));
for ($i = 0; $i < count($friend_location); $i++) {
    if ($friend_location[$i]['current_location']) {
        $result = $obj->getCoordinates($friend_location[$i]['current_location']);
        if ($result['lat'] != 0 and $result['lng'] != 0) {
            $friend_location[$i]['current_location']['lat'] = $result['lat'];
            $friend_location[$i]['current_location']['lng'] = $result['lng'];
        }
    }
}
$jsonfriend = json_encode($friend_location);
echo $jsonfriend;