Codeigniter4アドレスから緯度と経度を取得

codeigniter4でgoogleapiを使用して、住所から緯度と経度を取得します。このチュートリアルでは、PHPCodeigniterで住所から緯度と経度を取得する方法を学習します。

PHPCodeigniterのアドレスから緯度と経度を取得する必要がある場合。Googleは、google geocodeAPIという名前のAPIを提供しています。このチュートリアルでは、このAPIを使用して、PHPCodeigniterのアドレスから緯度と経度を取得します。

まず、Google Maps Geocodingサービスを呼び出す前に、APIキーを取得する必要があります。

Codeigniter4アプリで住所から緯度と経度を取得する

以下の手順に従って、Google GeocodeAPIを使用してCodeigniterでLatitudeとLongitudeFromAddressを取得します。

ステップ1-キーでGoogleAPIを使用する

https://maps.google.com/maps/api/geocode/json?address='.$address.'&key=your_api_key

https://maps.google.com/maps/api/geocode/json?address='.$address.'&key=your_api_key

ステップ2–アドレスを取得するための関数を作成する

次に、2つの関数を作成する必要があります。1つ目はgetl​​ocation()で、2つ目はget_longitude_latitude_from_adress()です。

作成した関数の説明

getlocation():-この関数でアドレスを渡すと、この関数内でget_longitude_latitude_from_adress()をアドレスとともにこの関数に呼び出し、アドレスから緯度と経度を返します。

get_longitude_latitude_from_adress():-この関数では、住所を渡し、この関数はgoogle geocode apisを呼び出して、住所から緯度と経度を取得します。

 public function getlocation()
{
    $address = "London united state";
    $array  = $this->get_longitude_latitude_from_adress($address);
    $latitude  = round($array['lat'], 6);
    $longitude = round($array['long'], 6);           
}
 
function get_longitude_latitude_from_adress($address){
  
$lat =  0;
$long = 0;
 
 $address = str_replace(',,', ',', $address);
 $address = str_replace(', ,', ',', $address);
 
 $address = str_replace(" ", "+", $address);
  try {
 $json = file_get_contents('https://maps.google.com/maps/api/geocode/json?address='.$address.'&key=your_api_key');
 $json1 = json_decode($json);
 
 if($json1->{'status'} == 'ZERO_RESULTS') {
 return [
     'lat' => 0,
     'lng' => 0
    ];
 }
 
 if(isset($json1->results)){
    
    $lat = ($json1->{'results'}[0]->{'geometry'}->{'location'}->{'lat'});
    $long = ($json1->{'results'}[0]->{'geometry'}->{'location'}->{'lng'});
  }
  } catch(exception $e) { }
 return [
 'lat' => $lat,
 'lng' => $long
 ];
}

注:-これらの関数をCodeigniterヘルパーに配置し、住所から緯度と経度を取得する場所で関数を呼び出すこともできます。

結論

codeigniterはアドレスの例から緯度と経度を取得します。GoogleAPIを使用してcodeigniter4でGoogleマップを表示せずに、アドレスから緯度と経度を取得する方法を学習しました。

リンク: https://www.tutsmake.com/codeigniter-4-get-latitude-and-longitude-from-address/

#codeigniter 

What is GEEK

Buddha Community

Codeigniter4アドレスから緯度と経度を取得

Codeigniter4アドレスから緯度と経度を取得

codeigniter4でgoogleapiを使用して、住所から緯度と経度を取得します。このチュートリアルでは、PHPCodeigniterで住所から緯度と経度を取得する方法を学習します。

PHPCodeigniterのアドレスから緯度と経度を取得する必要がある場合。Googleは、google geocodeAPIという名前のAPIを提供しています。このチュートリアルでは、このAPIを使用して、PHPCodeigniterのアドレスから緯度と経度を取得します。

まず、Google Maps Geocodingサービスを呼び出す前に、APIキーを取得する必要があります。

Codeigniter4アプリで住所から緯度と経度を取得する

以下の手順に従って、Google GeocodeAPIを使用してCodeigniterでLatitudeとLongitudeFromAddressを取得します。

ステップ1-キーでGoogleAPIを使用する

https://maps.google.com/maps/api/geocode/json?address='.$address.'&key=your_api_key

https://maps.google.com/maps/api/geocode/json?address='.$address.'&key=your_api_key

ステップ2–アドレスを取得するための関数を作成する

次に、2つの関数を作成する必要があります。1つ目はgetl​​ocation()で、2つ目はget_longitude_latitude_from_adress()です。

作成した関数の説明

getlocation():-この関数でアドレスを渡すと、この関数内でget_longitude_latitude_from_adress()をアドレスとともにこの関数に呼び出し、アドレスから緯度と経度を返します。

get_longitude_latitude_from_adress():-この関数では、住所を渡し、この関数はgoogle geocode apisを呼び出して、住所から緯度と経度を取得します。

 public function getlocation()
{
    $address = "London united state";
    $array  = $this->get_longitude_latitude_from_adress($address);
    $latitude  = round($array['lat'], 6);
    $longitude = round($array['long'], 6);           
}
 
function get_longitude_latitude_from_adress($address){
  
$lat =  0;
$long = 0;
 
 $address = str_replace(',,', ',', $address);
 $address = str_replace(', ,', ',', $address);
 
 $address = str_replace(" ", "+", $address);
  try {
 $json = file_get_contents('https://maps.google.com/maps/api/geocode/json?address='.$address.'&key=your_api_key');
 $json1 = json_decode($json);
 
 if($json1->{'status'} == 'ZERO_RESULTS') {
 return [
     'lat' => 0,
     'lng' => 0
    ];
 }
 
 if(isset($json1->results)){
    
    $lat = ($json1->{'results'}[0]->{'geometry'}->{'location'}->{'lat'});
    $long = ($json1->{'results'}[0]->{'geometry'}->{'location'}->{'lng'});
  }
  } catch(exception $e) { }
 return [
 'lat' => $lat,
 'lng' => $long
 ];
}

注:-これらの関数をCodeigniterヘルパーに配置し、住所から緯度と経度を取得する場所で関数を呼び出すこともできます。

結論

codeigniterはアドレスの例から緯度と経度を取得します。GoogleAPIを使用してcodeigniter4でGoogleマップを表示せずに、アドレスから緯度と経度を取得する方法を学習しました。

リンク: https://www.tutsmake.com/codeigniter-4-get-latitude-and-longitude-from-address/

#codeigniter 

伊藤  直子

伊藤 直子

1637686860

Codeigniter4アドレスから緯度と経度を取得

このチュートリアルでは、PHPCodeigniterで住所から緯度と経度を取得する方法を学習します。

PHPCodeigniterのアドレスから緯度と経度を取得する必要がある場合。Googleは、google geocodeAPIという名前のAPIを提供しています。このチュートリアルでは、このAPIを使用して、PHPCodeigniterのアドレスから緯度と経度を取得します。

まず、Google Maps Geocodingサービスを呼び出す前に、APIキーを取得する必要があります。

まず、https//cloud.google.com/maps-platform/?_ ga = 2.27293823.277869946.1577356888-568469380.1576660626# get- startedにアクセスして、APIキーを取得する必要があります。

GoogleコンソールからAPIキーを取得する手順:

  1. Google Cloud PlatformConsoleにアクセスし ます
  2. プロジェクトドロップダウンをクリックして、APIキーを追加するプロジェクトを選択または作成します。
  3. メニューボタンをクリックして、[ APIとサービス]> [資格情報]を選択し ます
  4. 上の 資格情報の ページ、クリックし た資格情報> APIキーを作成します
    APIキーの作成 ]ダイアログに、新しく作成したAPIキーが表示されます。
  5. [閉じる]をクリックし ます。
    新しいAPIキーは、[認証情報] ページの[ APIキー]の下に 一覧表示され ます
    ( 本番環境で使用する前に、APIキー制限することを忘れないでください 。)

Codeigniter4アプリで住所から緯度と経度を取得する

以下の手順に従って、Google GeocodeAPIを使用してCodeigniterでLatitudeとLongitudeFromAddressを取得します。

ステップ1-キーでGoogleAPIを使用する

https://maps.google.com/maps/api/geocode/json?address='.$address.'&key=your_api_key

ステップ2–アドレスを取得するための関数を作成する

次に、2つの関数を作成する必要があります。1つ目はgetl​​ocation()で、2つ目はget_longitude_latitude_from_adress()です。

作成した関数の説明

getlocation():-この関数でアドレスを渡すと、この関数内でget_longitude_latitude_from_adress()をアドレスとともにこの関数に呼び出し、アドレスから緯度と経度を返します。

get_longitude_latitude_from_adress():-この関数では、住所を渡し、この関数はgoogle geocode apisを呼び出して、住所から緯度と経度を取得します。

public function getlocation()
{
    $address = "London united state";
    $array  = $this->get_longitude_latitude_from_adress($address);
    $latitude  = round($array['lat'], 6);
    $longitude = round($array['long'], 6);           
}
 
function get_longitude_latitude_from_adress($address){
  
$lat =  0;
$long = 0;
 
 $address = str_replace(',,', ',', $address);
 $address = str_replace(', ,', ',', $address);
 
 $address = str_replace(" ", "+", $address);
  try {
 $json = file_get_contents('https://maps.google.com/maps/api/geocode/json?address='.$address.'&key=your_api_key');
 $json1 = json_decode($json);
 
 if($json1->{'status'} == 'ZERO_RESULTS') {
 return [
     'lat' => 0,
     'lng' => 0
    ];
 }
 
 if(isset($json1->results)){
    
    $lat = ($json1->{'results'}[0]->{'geometry'}->{'location'}->{'lat'});
    $long = ($json1->{'results'}[0]->{'geometry'}->{'location'}->{'lng'});
  }
  } catch(exception $e) { }
 return [
 'lat' => $lat,
 'lng' => $long
 ];
}
 

注:-これらの関数をCodeigniterヘルパーに配置し、住所から緯度と経度を取得する場所で関数を呼び出すこともできます。

結論

codeigniterはアドレスの例から緯度と経度を取得します。GoogleAPIを使用してcodeigniter4でGoogleマップを表示せずに、アドレスから緯度と経度を取得する方法を学習しました。

リンク: https://www.tutsmake.com/codeigniter-4-get-latitude-and-longitude-from-address/

#codeigniter 

坂本  健一

坂本 健一

1637829960

Codeigniter4アドレスから緯度と経度を取得

codeigniter4でgoogleapiを使用して、住所から緯度と経度を取得します。このチュートリアルでは、PHPCodeigniterで住所から緯度と経度を取得する方法を学習します。

PHPCodeigniterのアドレスから緯度と経度を取得する必要がある場合。Googleは、google geocodeAPIという名前のAPIを提供しています。このチュートリアルでは、このAPIを使用して、PHPCodeigniterのアドレスから緯度と経度を取得します。

まず、Google Maps Geocodingサービスを呼び出す前に、APIキーを取得する必要があります。

まず、https//cloud.google.com/maps-platform/?_ ga = 2.27293823.277869946.1577356888-568469380.1576660626# get- startedにアクセスして、APIキーを取得する必要があります。

GoogleコンソールからAPIキーを取得する手順:

  1. Google Cloud PlatformConsoleにアクセスし ます
  2. プロジェクトのドロップダウンをクリックして、APIキーを追加するプロジェクトを選択または作成します。
  3. メニューボタンをクリックして、[ APIとサービス]> [資格情報]を選択し ます
  4. 上の 資格情報の ページ、クリックし た資格情報> APIキーを作成します
    APIキーの作成 ]ダイアログに、新しく作成したAPIキーが表示されます。
  5. [閉じる]をクリックし ます。
    新しいAPIキーは、[認証情報] ページの[ APIキー]の下に 一覧表示され ます
    ( 本番環境で使用する前に、APIキー制限することを忘れないでください 。)

Codeigniter4アプリで住所から緯度と経度を取得する

以下の手順に従って、Google GeocodeAPIを使用してCodeigniterでLatitudeとLongitudeFromAddressを取得します。

ステップ1-キーでGoogleAPIを使用する

https://maps.google.com/maps/api/geocode/json?address='.$address.'&key=your_api_key

https://maps.google.com/maps/api/geocode/json?address='.$address.'&key=your_api_key

ステップ2–アドレスを取得するための関数を作成する

次に、2つの関数を作成する必要があります。1つ目はgetl​​ocation()で、2つ目はget_longitude_latitude_from_adress()です。

作成した関数の説明

getlocation():-この関数でアドレスを渡すと、この関数内でget_longitude_latitude_from_adress()をアドレスとともにこの関数に呼び出し、アドレスから緯度と経度を返します。

get_longitude_latitude_from_adress():-この関数では、住所を渡し、この関数はgoogle geocode apisを呼び出して、住所から緯度と経度を取得します。

public function getlocation()
{
    $address = "London united state";
    $array  = $this->get_longitude_latitude_from_adress($address);
    $latitude  = round($array['lat'], 6);
    $longitude = round($array['long'], 6);           
}
 
function get_longitude_latitude_from_adress($address){
  
$lat =  0;
$long = 0;
 
 $address = str_replace(',,', ',', $address);
 $address = str_replace(', ,', ',', $address);
 
 $address = str_replace(" ", "+", $address);
  try {
 $json = file_get_contents('https://maps.google.com/maps/api/geocode/json?address='.$address.'&key=your_api_key');
 $json1 = json_decode($json);
 
 if($json1->{'status'} == 'ZERO_RESULTS') {
 return [
     'lat' => 0,
     'lng' => 0
    ];
 }
 
 if(isset($json1->results)){
    
    $lat = ($json1->{'results'}[0]->{'geometry'}->{'location'}->{'lat'});
    $long = ($json1->{'results'}[0]->{'geometry'}->{'location'}->{'lng'});
  }
  } catch(exception $e) { }
 return [
 'lat' => $lat,
 'lng' => $long
 ];
}

注:-これらの関数をCodeigniterヘルパーに配置し、住所から緯度と経度を取得する場所で関数を呼び出すこともできます。

結論

codeigniterはアドレスの例から緯度と経度を取得します。GoogleAPIを使用してcodeigniter4でGoogleマップを表示せずに、アドレスから緯度と経度を取得する方法を学習しました。

リンク: https://www.tutsmake.com/codeigniter-4-get-latitude-and-longitude-from-address/

#codeigniter