1
A
回答
0
做搜索後,你可以得到座標低谷place.Point.coordinates
例如:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps API Sample</title>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAA1XbMiDxx_BTCY2_FkPh06RRaGTYH6UMl8mADNa0YKuWNNa8VNxQEerTAUcfkyrr6OwBovxn7TDAH5Q"></script>
<script type="text/javascript">
var map;
var geocoder;
function initialize() {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(34, 0), 1);
geocoder = new GClientGeocoder();
}
// addAddressToMap() is called when the geocoder returns an
// answer. It adds a marker to the map with an open info window
// showing the nicely formatted version of the address and the country code.
function addAddressToMap(response) {
map.clearOverlays();
if (!response || response.Status.code != 200) {
alert("Sorry, we were unable to geocode that address");
} else {
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);
marker = new GMarker(point);
map.addOverlay(marker);
--> // here you get the coordinates of the founded point
marker.openInfoWindowHtml('<b>Coordinates:</b> ' + place.Point.coordinates);
}
}
// showLocation() is called when you click on the Search button
// in the form. It geocodes the address entered into the form
// and adds a marker to the map at that location.
function showLocation() {
var address = document.forms[0].q.value;
geocoder.getLocations(address, addAddressToMap);
}
// findLocation() is used to enter the sample addresses into the form.
function findLocation(address) {
document.forms[0].q.value = address;
showLocation();
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()" style="font-family: Arial;border: 0 none;">
<!-- Creates a simple input box where you can enter an address
and a Search button that submits the form. //-->
<form action="#" onsubmit="showLocation(); return false;">
<p>
<b>Search cities:</b>
<input type="text" name="q" value="" class="address_input" size="40" />
<input type="submit" name="find" value="Search" />
</p>
</form>
<div id="map_canvas" style="width: 500px; height: 300px"></div>
</body>
</html>
相關問題
- 1. 從城市名稱獲取經緯度
- 2. 從經緯度獲取城市名稱
- 3. 如何獲得城市中所有地區的經緯度值
- 4. 如何獲得谷歌地圖中的城市GLatLngBounds
- 5. 谷歌地圖獲得城市界限,繪製城市多邊形
- 6. 如何獲得按城市+谷歌地圖上的zipCode的距離API
- 7. 獲得來自谷歌Places API的城市的地方ID
- 8. 如何執行谷歌地圖搜索街道名稱,城市?
- 9. 從經緯度得到國家,地區和城市名稱(PHP)
- 10. 谷歌地圖(反向)地理編碼API應該只顯示城市名稱
- 11. 如何在谷歌地圖上標記一個城市
- 12. 地理與城市名稱,谷歌地圖編碼
- 13. 如何從谷歌地圖導出城市巴士所有站點的名稱,緯度和經度?
- 14. 如何在谷歌地圖上通過IP獲取城市名稱?
- 15. 過濾城市的經緯度與其他城市的距離(經緯度)?
- 16. 如何獲得特定國家的國家和城市 - 谷歌地圖api
- 17. 如何從離子2中的谷歌地圖獲取城市名稱
- 18. 獲得來自谷歌地圖的所有城市的名字 - 通過縣
- 19. 地理位置 - 如何從長期獲得城市和緯度
- 20. 谷歌地圖將API放到只返回城市?
- 21. 如何在JavaScript中找到經緯度的城市名稱?
- 22. 使用HTML獲取城市名稱的經緯度,bing地圖中的js
- 23. 我能得到城市,從谷歌地圖API
- 24. 從給定的城市名稱獲取經度和緯度的簡單API
- 25. 哪個地理服務(如果有的話)可以返回城市中心的經緯度和城市半徑給定城市名稱?
- 26. 經度和城市的緯度使用內部消除谷歌地圖
- 27. 要獲取緯度和長度的城市的地理編碼區域名稱
- 28. 如何限制Android谷歌地圖到一個城市?
- 29. API鍵入城市名稱並獲取可能的城市列表?
- 30. iPhone中的Google地圖 - 經度和緯度的城市和州名稱
字面上只有這個城市嗎?這將是有問題的,因爲給定的城市名稱可能代表許多不同的地點。城市名稱沒有唯一性。 – Thomas 2010-03-14 02:01:18