Exemple #1
0
     }
 }
 public function actionTest()
 {
     $this->layout = false;
     $this->render('test');
 }
 public function actionLoadmapdetail($listing_id, $size = 'small_map')
 {
     $this->layout = false;
     Yii::app()->clientScript->registerCoreScript('jquery');
     $model = Listing::model()->findByPk($listing_id);
     $this->render('load_map_detail', array('model' => $model, 'size' => $size));
 }
 /********* Mar 04, 2015 ANH DUNG FOR IMPORT NEW DATA Postal Code *********/
 /********* STEP TO UPDATE THIS 6-Digit Postal Code  ********
Exemple #2
0
 /**
 * @Author: ANH DUNG Mar 05, 2015
 * @Todo: curl to get long and lat
 * @Param: $postal_code
 * @Return: array[long]
 * @Note: $postal_code='428802' is line 50504 in file postcode.txt
 * CurlToGetLongLat
 * Respone CURL
 * Array
     (
     [0] => stdClass Object
    (
        [total] => 1
    )
 
     [1] => stdClass Object
    (
        [id] => 303416
        [v] => #1 Suites (U/C - TOP : 31 Dec 2018)
        [i] => 1 Lorong 20 Geylang. (S)398721
        [t] => 1
        [pid] => 100869
        [aid] => 51869
        [lid] => 303416
        [lon] => 103.881572
        [lat] => 1.31253
        [ad] => 0
        [c] => 1084
        [bld] => 1
        [hsp] => 1
    )
     )
 */
 public static function CurlToGetLongLat($building_name, $postal_code = '428802')
 {
     // 1. sau khi co dc $buildkey tu table ApiBuilding => then like $buildkey ben bang table postal code de tim postal code
     // 2. sau khi tim dc $postal_code thi call ham actionImportBuilding
     // 3. Lay building name: => quay lai table building lay tu ky tu 7 den 45  ( la building name )
     // tuong duong voi $buildkey hoi nay find ra postal code
     // 4. sau khi CURL tra ve se isset de so khop phan tu [v] => 112 Katong voi cai building name trong table ApiBuilding
     //$link = 'http://www.streetdirectory.com/api/?mode=search&output=json&methods=all&country=sg&q='.trim($buildname);
     $url = "http://www.streetdirectory.com/api/?mode=search&&output=json&profile=sd_auto&country=sg&q=" . trim($postal_code);
     $output = MyFormat::curl_get_contents($url);
     //            $nearBy=file_get_contents($link);
     $aRes = array();
     $output = json_decode($output);
     if (is_array($output)) {
         foreach ($output as $key => $item) {
             if ($key == 1) {
                 // nếu có 1 item trả về thì chính là nó không cần check isset($item->v)
                 $aRes['long_street'] = $item->lon;
                 $aRes['lat_street'] = $item->lat;
             }
             if (isset($item->v)) {
                 $building_name_res = trim(strtolower($item->v));
                 $building_name_local = trim(strtolower($building_name));
                 if ($building_name_res == $building_name_local) {
                     $aRes['long_street'] = $item->lon;
                     $aRes['lat_street'] = $item->lat;
                     break;
                 }
             }
         }
     }
     return $aRes;
 }