Ben Geocoding için birden webservices (yani Google, Yahoo, Bing, vb) kullanabileceği bir Geocoding sınıfını inşa ediyorum iç içe. Ben böyle yeni webservices kolayca konfigüre edilebilir bir yol yapmaya çalışıyorum. webservices çoğu benim birincil odak noktası olarak XML seçti PHP .. Ya XML/JSON dönmek. Tüm kod yer zaten, ama mesela artık Google (a simple_xml_element şekilde değiştirilmiş) aşağıdaki XMLDinamik erişim nesnesi
SimpleXMLElement Object
(
[status] => OK
[result] => Array
(
[0] => SimpleXMLElement Object
(
[type] => postal_code
[formatted_address] => 1010 Lausanne, Switzerland
[address_component] => Array
(
[0] => SimpleXMLElement Object
(
[long_name] => 1010
[short_name] => 1010
[type] => postal_code
)
[1] => SimpleXMLElement Object
(
[long_name] => Lausanne
[short_name] => Lausanne
[type] => Array
(
[0] => locality
[1] => political
)
)
[2] => SimpleXMLElement Object
(
[long_name] => Vaud
[short_name] => VD
[type] => Array
(
[0] => administrative_area_level_1
[1] => political
)
)
[3] => SimpleXMLElement Object
(
[long_name] => Switzerland
[short_name] => CH
[type] => Array
(
[0] => country
[1] => political
)
)
)
[geometry] => SimpleXMLElement Object
(
[location] => SimpleXMLElement Object
(
[lat] => 46.5376186
[lng] => 6.6539665
)
[location_type] => APPROXIMATE
[viewport] => SimpleXMLElement Object
(
[southwest] => SimpleXMLElement Object
(
[lat] => 46.5253574
[lng] => 6.6384420
)
[northeast] => SimpleXMLElement Object
(
[lat] => 46.5467887
[lng] => 6.6745222
)
)
[bounds] => SimpleXMLElement Object
(
[southwest] => SimpleXMLElement Object
(
[lat] => 46.5253574
[lng] => 6.6384420
)
[northeast] => SimpleXMLElement Object
(
[lat] => 46.5467887
[lng] => 6.6745222
)
)
)
)
)
ihtiyacım bilgiler [konum] etiketinde olduğu döndürür, bu yüzden yolunu depolamak denedim bir var içinde:
(suppose $xml is the object)
$xml->{$lat_path};
Ama bu işi doens't:
$lat_path = 'result[0]->geometry->location->lat;
Ve sonra değerini bu şekilde erişmeyi deneyin. Bilgiye dinamik veya değişken tabanlı olarak erişebilmemin herhangi bir yolu var mı? Google özel kodu ile benim Coğrafi Kodlama yöntemi mahvetmek istemiyoruz.
Teşekkürler!
. (eğer xml'den bazılarını gösterebilirseniz, örnek bir uygulama sağlamaya çalışacağım) – Yoshi
Bunun için bir yöntem yazabilir ve unutabilirsiniz .. – Vytautas
Ayrıca Xpath kullanmayı denedim, ama işe yaramadı :( print_r ($ xml> XPath ('geometri/Yer')); bana boş bir dizi vermiştir. –