みんなに優しく、解りやすくをモットーに開設しています。 以下のルールを守りみんなで助け合いましょう。
1.ファイルメーカーで解らない事があればここで質問して下さい。 何方でも、ご質問・ご回答お願いします。 (優しく回答しましょう)
You are not logged in.
Pages: 1
始めて質問します、GoogleMapAPIからjsonで取り出したデータから住所データだけをとりだすほうほうを教えてください。
よろしくお願いします。こちらはプログラムの知識は全くありませんよろしくお願いいたします、できればFileMakerでフィールド設定して取り出したいのですがサンプルコードなど教えていただければ助かります。
フィールド設定でurl挿入で"https://maps.googleapis.com/maps/api/geocode/json?latlng="&位置データ::LatLng&"
&location_type=ROOFTOP&result_type=street_address&key=" "&language=ja"でリクエスト
返り値
{
"plus_code" : {
"compound_code" : "PH8V+JF 日本、東京都東京",
"global_code" : "8Q7XPH8V+JF"
},
"results" : [
{
"address_components" : [
{
"long_name" : "",
"short_name" : "",
"types" : [ "premise" ]
},
{
"long_name" : "",
"short_name" : "",
"types" : [ "political", "sublocality", "sublocality_level_4" ]
},
{
"long_name" : "丁目",
"short_name" : "丁目",
"types" : [ "political", "sublocality", "sublocality_level_3" ]
},
{
"long_name" : "",
"short_name" : "",
"types" : [ "political", "sublocality", "sublocality_level_2" ]
},
{
"long_name" : "杉並区",
"short_name" : "杉並区",
"types" : [ "locality", "political" ]
},
{
"long_name" : "東京都",
"short_name" : "東京都",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "日本",
"short_name" : "JP",
"types" : [ "country", "political" ]
},
{
"long_name" : "167-",
"short_name" : "167-",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "日本、〒167- 東京都杉並区" "丁目 ",
"geometry" : {
"location" : {
"lat" : 35.7165072,
"lng" : 139.5937044
},
"location_type" : "ROOFTOP",
"viewport" : {
"northeast" : {
"lat" : 35.71785618029151,
"lng" : 139.5950533802915
},
"southwest" : {
"lat" : 35.71515821970851,
"lng" : 139.5923554197085
}
}
},
"place_id" : "ChIJXyKlt2juGGARDNc7ZDsdswE",
"plus_code" : {
"compound_code" : "PH8V+JF 日本、東京都 東京",
"global_code" : "8Q7XPH8V+JF"
},
"types" : [ "street_address" ]
}
],
"status" : "OK"
}
から"formatted_address"だけ取り出したいのですがどなたかご教授お願いいたします
Offline
返り値を$jsonという変数で受けたとして、
JSONGetElement ( $json;"results[0].formatted_address" )
で取れると思います。
Offline
戻りJSON構文の50行目
『"formatted_address" : "日本、〒167- 東京都杉並区" "丁目 ",』
にタイポがあるからでは?(※「""」囲み内に入れ子の「"」がある)
タイポ補正してからJSON計算すれば良いかな?
・ JSONGetElement ( $json;"results[0].formatted_address" )
↓
・ JSONGetElement ( Substitute($json; [Quote(" ");" "]);"results[0].formatted_address" )
Offline
calafate様アドバイスありがとうございました。解決しました。
Offline
Pages: 1
[ Generated in 0.004 seconds, 7 queries executed - Memory usage: 517.59 KiB (Peak: 522.13 KiB) ]