-1
A
回答
2
2
下面給出的(地址查詢)是代碼。只需添加位置並點擊地理編碼按鈕。
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Geocoding service</title>
<style>
html, body{
margin: 0px;
padding: 0px;
}
#panel {
position: absolute;
top: 5px;
left: 50%;
margin-left: -180px;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid #999;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false"></script>
<script>
var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(-34.397, 150.644);
var mapOptions = {
zoom: 13,
center: latlng
}
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
}
function codeAddress() {
document.getElementById("dis").setAttribute('style','visibility:visible;');
var address = document.getElementById('address').value;
geocoder.geocode({ 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<style type="text/css">
.display{visibility:hidden ;width: 700px;height: 400px;position: fixed;top: 0;left: 0;right: 0;bottom: 0;margin: auto;}
</style>
</head>
<body>
<div id="panel">
<input id="address" type="textbox" value="Pathankot">
<input type="button" value="Geocode" onclick="codeAddress()">
</div>
<div class="display" id="dis">
<div id="map-canvas" style="width:400px;height:400px"></div>
</div>
</body>
</html>
相關問題
- 1. 在谷歌地圖中查找位置
- 2. 谷歌地圖查找地址
- 3. 谷歌地圖上的定位地址
- 4. 在谷歌地圖中查找多個位置的中心
- 5. 谷歌地圖中的地理位置
- 6. 谷歌地圖API找不到位置
- 7. 如何在Android中查找當前位置的谷歌地圖?
- 8. 如何在谷歌地圖iOS中查找當前位置?
- 9. 在谷歌地圖上的位置的字符串地址
- 10. 設置谷歌地圖標記的位置(地址?)
- 11. 谷歌地圖smartinfowindow位置
- 12. 谷歌地圖API查詢位置
- 13. 谷歌地圖在html中的地址
- 14. 查找谷歌地圖
- 15. Android谷歌地圖查找
- 16. 谷歌地圖網址 - 地圖中心
- 17. 地理位置谷歌地圖v2
- 18. 谷歌地圖:地理位置援助
- 19. 谷歌地圖API(地理位置)
- 20. 地理位置谷歌地圖jquery
- 21. 地理位置與谷歌地圖V3
- 22. 在谷歌地圖上設置位置
- 23. 在谷歌地圖上查找我的位置
- 24. 在谷歌地圖上查找gps的位置
- 25. 加載位置到谷歌地圖 - 谷歌地圖v2
- 26. 谷歌地圖和jQuery谷歌地圖api的位置差異
- 27. 谷歌地圖問題DB的地址位置
- 28. 顯示地址位置與谷歌地圖onload
- 29. 從谷歌地圖經緯度獲取位置地址
- 30. 不同地址的谷歌地圖位置onclick
這個網站可能是你https://developers.google.com/maps/ –
這個幫助是一個例子https://developers.google.com/maps/documentation/javascript/examples/place-search –