是否有通過一個地址解析請求發送多個地址的一種方法:谷歌地址解析器的限制
geocoder.geocode({ 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
addMarker(results[0].geometry.location);
var the_string = generate_string(elements, a, address);
infowindow[a] = new google.maps.InfoWindow({
content: the_string
});
google.maps.event.addListener(markersArray[a], "click", function() {
infowindow[a].open(map, markersArray[a]);
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
其中地址包含地址的陣列。原因是我跨越「OVER_QUERY_LIMIT」來解決這裏OVER_QUERY_LIMIT while using google maps這裏Google Map Javascript API v3 - OVER_QUERY_LIMIT Error
我想知道如果我應該開始使用在客戶端的服務器端版本或繼續使用JavaScript API並獲得通過發送地址數組幫助地理編碼器調用?
在你的意見或經驗,如果我有一個應用程序,你可以輸入無盡的地址到字段中,然後按「繪製地圖」按鈕,你會怎麼做這個在API調用,地理編碼等等?
編輯:////////////////////////
我現在使用此代碼:
class geocoder{
static private $url = "http://maps.google.com/maps/api/geocode/json?sensor=false&address=";
static public function getLocation($address){
$url = self::$url.urlencode($address);
$resp_json = self::curl_file_get_contents($url);
$resp = json_decode($resp_json, true);
if($resp['status']='OK'){
return $resp['results'][0]['geometry']['location'];
}else{
return false;
}
}
static private function curl_file_get_contents($URL){
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $URL);
$contents = curl_exec($c);
curl_close($c);
if ($contents) return $contents;
else return FALSE;
}
}
並調用它像這樣:
$address = urlencode($field_set["value"]);
$loc = geocoder::getLocation($address);
在每一個地址的環路
被放置在(在這種情況下的20倍)。
它只在地圖上放置10個標記,無論正確地使用2個不同的lng和lats。
它在過去的10個LAT LNGS返回null:■
編輯:///////////////////////////
我已經把一個睡在調用此循環:
$loc = geocoder::getLocation($address);
每8個地理編碼,它停止了第二然後繼續..這似乎讓所有的地理編碼器的位置被正確地渲染...但它看起來像一個絨毛。
任何想法?
可能重複http://stackoverflow.com/questions/396819/geocode-multiple-addresses – Ravi
不是。也見過;)。我會更好我的問題,雖然:)。我想知道是否可以使用javascript api而不是服務器端來完成。 – Jimmyt1988
好吧......我只是覺得它可能會給你一個快速的解決方案。 – Ravi