1
我在我的頁面有一個textbox
,得到location
名稱和button
並帶有文本getLat&Long
。現在在clicking
我的按鈕我必須顯示textbox
中位置的latitude
和longitude
的alert
。任何建議?
請不要給我建議作爲googleapis b'coz它的一些階段限制後,此限制要支付這一點。 這是我嘗試用googleapis
: -使用javascript獲取緯度和經度
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function myIP(){
$("#btn").click(function(){
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': '#city'}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
alert("location : " + results[0].geometry.location.lat() + " " +results[0].geometry.location.lng());
} else {
alert("Something got wrong " + status);
}
});
});
}
</script>
</head>
<body onload="myIP()">
<input type="text" id= "city">
<input id="btn" type="button" value="get Lat&Long" />
</body>
</html>
感謝。
你能展示一些代碼嗎? – plalx 2013-04-20 05:04:40
@plalx添加我的代碼。但我使用'googleapis'我不喜歡這個任何其他想法,然後建議。謝謝。 – 2013-04-20 05:08:21