Ejemplo n.º 1
0
 for ($index = 1; $index <= $total / Model_Store::NUM_PER_PAGE + 1; $index++) {
     $allStores = $objStore->getAllStore($index);
     //print_r($allStores);
     //break;
     foreach ($allStores as $store) {
         // print_r($store);
         //add urlencode to your address
         $rawAddr = $store[global_mapping::Address] . ', ' . $store[global_mapping::DistrictName] . ', ' . str_replace("TP.", "", $store[global_mapping::CityName]) . ', Việt Nam';
         //$address = urlencode($rawAddr);
         //$address = str_replace(" ", "+", $address);
         //echo $rawAddr;
         if ($store[global_mapping::Latitude] == '10.8230990000' && $store[global_mapping::Longitude] == '106.6296640000') {
             echo '<br>Start get lat long: ' . $rawAddr;
             //$json = file_get_contents("http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false");
             //$json = json_decode($json);
             $mapLocation = global_common::getLocation($_gmapAPI, $rawAddr);
             $lat = $mapLocation['lat'];
             $long = $mapLocation['long'];
             if ($lat && $long) {
                 $result = $objStore->update($store[global_mapping::StoreID], $store[global_mapping::Name], $store[global_mapping::Address], $store[global_mapping::DistrictID], $store[global_mapping::CityID], $store[global_mapping::Phone], $store[global_mapping::SpecialDesc], $lat, $long, $store[global_mapping::WorkingDay], $store[global_mapping::MainCategoryId], $store[global_mapping::StoreIcon], $store[global_mapping::StoreImage], $store[global_mapping::Status], $store[global_mapping::CreatedBy], $store[global_mapping::CreatedDate], $store[global_mapping::UpdatedBy], $store[global_mapping::UpdatedDate], $store[global_mapping::DeletedBy], $store[global_mapping::DeletedDate]);
                 if ($result) {
                     echo "<br>Update successfull " . "Name:" . $store[global_mapping::Name] . " Address:" . $store[global_mapping::Address];
                 } else {
                     echo "<br>Update failed " . "Name:" . $store[global_mapping::Name] . " Address:" . $store[global_mapping::Address];
                 }
             } else {
                 echo "<br>Update failed. Can't get geo of " . "Name:" . $store[global_mapping::Name] . " Address:" . $store[global_mapping::Address];
             }
         } else {
             echo "<br>Update already." . "Name:" . $store[global_mapping::Name] . " Address:" . $store[global_mapping::Address];
         }