Search
 
SCRIPT & CODE EXAMPLE
 

PHP

get_distance

   function get_distance($lat1, $lat2, $long1, $long2)
    {
        $url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=".$lat1.",".$long1."&destinations=".$lat2.",".$long2."&key= &mode=driving&language=pl-PL";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        $response = curl_exec($ch);
        curl_close($ch);
        $response_a = json_decode($response, true);

        $status = "ERROR";
        $dist   = 0;
        $time   = 0;
        if($response_a['rows'][0]['elements'][0]['status'] === 'OK') {
            $dist   = $response_a['rows'][0]['elements'][0]['distance']['value'];
            $time   = $response_a['rows'][0]['elements'][0]['duration']['text'];
            $status = "OK";
        }

        return array('status' => $status, 'distance' => $dist, 'time' => $time);
    }
Comment

get_distance

   function get_distance($lat1, $lat2, $long1, $long2)
    {
        $url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=".$lat1.",".$long1."&destinations=".$lat2.",".$long2."&key= &mode=driving&language=pl-PL";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        $response = curl_exec($ch);
        curl_close($ch);
        $response_a = json_decode($response, true);

        $status = "ERROR";
        $dist   = 0;
        $time   = 0;
        if($response_a['rows'][0]['elements'][0]['status'] === 'OK') {
            $dist   = $response_a['rows'][0]['elements'][0]['distance']['value'];
            $time   = $response_a['rows'][0]['elements'][0]['duration']['text'];
            $status = "OK";
        }

        return array('status' => $status, 'distance' => $dist, 'time' => $time);
    }
Comment

PREVIOUS NEXT
Code Example
Php :: adding field to array on condition laravel 
Php :: Stopping On First Validation Failure 
Php :: distance between two locations in php 
Php :: wordpress function _() not working 
Php :: laravel add model to one to many relationship 
Php :: how to superscript th in php date 
Php :: Remove auto generate p from category description 
Php :: set additional params to form laravel 
Php :: lengthawarepaginator gives keys on page 2 
Php :: php specific function to Unflatten array 
Php :: change php variable value in javascript 
Php :: php make text id attribute safe 
Php :: Settings pages are created like this: 
Php :: herencia php 
Php :: livewire layout error 
Php :: $var = 1 / 2; in php 
Php :: change varchar limit in migration file. 
Php :: css en linea php 
Php :: carbon in laravel documentation 
Php :: Deprecated: WC_Product::get_dimensions error fix 
Php :: Yii::$app-session 
Php :: php get docblock with reflection 
Php :: make_dpcust 
Php :: describe request php-salesforce-rest-api 
Php :: BelongsToMany relations pivot fields are null in Livewire refresh 
Php :: white labeling wordpress divi 
Php :: phpdoc array type 
Php :: Régler l’enregistrement automatique dans WordPress 
Php :: conect_from_db_datalayer 
Php :: check website ssl certificate using php openssl_x509_parse 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =