config("site.baidu_ak"), "origin" => $origin, "destination" => $destination, "steps_info" => 0 ] ); return new \SResult((int)(0 == $response->status), $response->message, 0 == $response->status ? $response->result->routes[0]->distance : null); } public static function geocoding($address) { $response = http_request("https://api.map.baidu.com/geocoding/v3/", [ "ak" => config("site.baidu_ak"), "output" => 'json', "address" => $address ] ); $code = (int)(0 == $response->status); return new \SResult( $code, $code == 0 ? $response->msg : null, 0 == $response->status ? ["lng" => $response->result->location->lng, "lat" => $response->result->location->lat] : null ); } }