Zend Gdataを使用して住所をジオコードする方法を知りましたが、返されたJSONの部分を取得する方法はわかりません。ここでジオコーダは次のとおりです。Zend Gdataを使用してGoogleマップを作成する
include_once('Zend/Gdata.php');
$client = new Zend_Http_Client('http://maps.googleapis.com/maps/api/geocode/json');
$urlencodedAddress = urlencode('1600 Pennsylvania Avenue, N.W. Washington, DC 20500');
$client->setParameterGet('sensor', 'false');
$client->setParameterGet('address', $urlencodedAddress);
$response = $client->request('GET');
、ここではレスポンスオブジェクトです:
Zend_Http_Response Object ([version:protected] => 1.1 [code:protected] => 200 [message:protected] => OK [headers:protected] => Array ([Content-type] => application/json; charset=UTF-8 [Date] => Mon, 30 Jan 2012 03:26:25 GMT [Expires] => Tue, 31 Jan 2012 03:26:25 GMT [Cache-control] => public, max-age=86400 [Vary] => Accept-Language [Server] => mafe [X-xss-protection] => 1; mode=block [X-frame-options] => SAMEORIGIN [Connection] => close) [body:protected] => { "results" : [ { "address_components" : [ { "long_name" : "1600", "short_name" : "1600", "types" : [ "street_number" ] }, { "long_name" : "Pennsylvania Ave NW", "short_name" : "Pennsylvania Ave NW", "types" : [ "route" ] }, { "long_name" : "Northwest Washington", "short_name" : "Northwest Washington", "types" : [ "neighborhood", "political" ] }, { "long_name" : "Washington", "short_name" : "Washington", "types" : [ "locality", "political" ] }, { "long_name" : "District of Columbia", "short_name" : "DC", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "United States", "short_name" : "US", "types" : [ "country", "political" ] }, { "long_name" : "20500", "short_name" : "20500", "types" : [ "postal_code" ] } ], "formatted_address" : "1600 Pennsylvania Ave NW, Washington, DC 20500, USA", "geometry" : { "location" : { "lat" : 38.89871490, "lng" : -77.03765550 }, "location_type" : "ROOFTOP", "viewport" : { "northeast" : { "lat" : 38.90006388029150, "lng" : -77.03630651970849 }, "southwest" : { "lat" : 38.89736591970851, "lng" : -77.03900448029150 } } }, "partial_match" : true, "types" : [ "street_address" ] } ], "status" : "OK" })
本当に私はスプリットマップ、マーカーによる通常1と分割ビューを作成するためのデータを使用したいですストリートビューを示しています。助言がありますか?
ありがとう、どうすれば結果のデータから位置を取得できますか? (lat)=> 38.900063880291 [lng] => -77.036306519708)[南西] => stdClassオブジェクト([lat] => 38.897365919709 [lng] => -77.039004480291)))[partial_match] => – savagenoob
あなたは今データを地図に追加しています。ここにgoogle maps javascript apiチュートリアル[Google Maps JavaScript API V3(Google Maps JavaScript API V3)があります。[1] [types] => Array([0] => street_address))) ](http://code.google.com/apis/maps/documentation/javascript/tutorial.html) – RockyFord