こんにちは、Google Geocode から経度と緯度の値を出力する必要があります。以下を使用してxmlを取得しました。
$url ="http://maps.googleapis.com/maps/api/geocode/xml?address=se18lu&sensor=false";
$result = simplexml_load_file($url);
そして、次を返します。
SimpleXMLElement Object
(
[status] => OK
[result] => SimpleXMLElement Object
(
[type] => postal_code
[formatted_address] => Bankside, London Borough of Lambeth, London SE1 8LU, UK
[address_component] => Array
(
[0] => SimpleXMLElement Object
(
[long_name] => SE1 8LU
[short_name] => SE1 8LU
[type] => postal_code
)
[1] => SimpleXMLElement Object
(
[long_name] => Bankside
[short_name] => Bankside
[type] => Array
(
[0] => sublocality
[1] => political
)
)
[2] => SimpleXMLElement Object
(
[long_name] => London
[short_name] => London
[type] => Array
(
[0] => locality
[1] => political
)
)
[3] => SimpleXMLElement Object
(
[long_name] => London Borough of Lambeth
[short_name] => London Borough of Lambeth
[type] => Array
(
[0] => administrative_area_level_3
[1] => political
)
)
[4] => SimpleXMLElement Object
(
[long_name] => Greater London
[short_name] => Gt Lon
[type] => Array
(
[0] => administrative_area_level_2
[1] => political
)
)
[5] => SimpleXMLElement Object
(
[long_name] => United Kingdom
[short_name] => GB
[type] => Array
(
[0] => country
[1] => political
)
)
)
[geometry] => SimpleXMLElement Object
(
[location] => SimpleXMLElement Object
(
[lat] => 51.5034227
[lng] => -0.1080750
)
[location_type] => APPROXIMATE
[viewport] => SimpleXMLElement Object
(
[southwest] => SimpleXMLElement Object
(
[lat] => 51.5020958
[lng] => -0.1094971
)
[northeast] => SimpleXMLElement Object
(
[lat] => 51.5047938
[lng] => -0.1067991
)
)
[bounds] => SimpleXMLElement Object
(
[southwest] => SimpleXMLElement Object
(
[lat] => 51.5032242
[lng] => -0.1087301
)
[northeast] => SimpleXMLElement Object
(
[lat] => 51.5036654
[lng] => -0.1075661
)
)
)
)
)
すべてが良いです。xml から long 値と tat 値を取得する必要がありますか? これらの値「緯度」のみを印刷/表示するにはどうすればよいですか???: たとえば
結果 -> 形状 -> 位置 -> 緯度