本文介绍了每次我使用地理编码API时如何在文本框中显示计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我想每次使用Geocode API绘制标记时都在文本框中显示计数数量,但是文本框中什么都没有显示.
如果我每次单击按钮都在运行用于显示计数的代码,则相同的逻辑将在文本框中显示数字,但是当将相同的逻辑与地理编码API一起使用时,则不会显示计数.谁能帮我解决问题吗?
提前谢谢.

Hi all,
I want to show number of counts in the text box for ever time i plot the marker using Geocode API but nothing is showing in the text box.
If i''m running the code for showing count every time i click on button then the same logic is showing numbers in text box but when using this same logic with geocode API so its not showing count.
Can anyone please please help me how to solve it?
Thanks in advance.

<!DOCTYPE html>
 <html>
 <head> 
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css"> 
html { height: 100% }   
body { height: 100%; margin: 0px; padding: 0px }   
#map_canvas { height: 100% } 
</style> 

<script type="text/javascript"     
src="http://maps.google.com/maps/api/js?sensor=false"> 
</script> 
<script type="text/javascript">
ct=0;
</script>
<script type="text/javascript">   
  
 
function codeAddress() {     
document.body.bgColor="steelblue";
geocoder = new google.maps.Geocoder();
var address = document.getElementById("address").value;     
latlng=new Array();
geocoder.geocode( { ''address'': address}, function(results, status) 
{       
if (status == google.maps.GeocoderStatus.OK) 
{ ct++;
document.getElementById("count").Value=ct; 
num=results.length;
for (i = 0; i < num; i++) {
 latlng[i] = results[i].geometry.location ;
   
} 
     
 var myOptions = {       
zoom: 8,       
center:  latlng[0],       
mapTypeId: google.maps.MapTypeId.ROADMAP     
}     
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
for (j = 0; j < num; j++) {
         
var marker = new google.maps.Marker({             
map: map,              
removed:  latlng[j]    
});   
}

} 
else 
{         
alert("Geocode was not successful for the following reason: " + status);      
}     
});
}
</script>
</head>  
<body> 
<div id="map_canvas" style="width: 320px; height: 480px;"></div>   
<div>     <input id="address" type="textbox" value="Sydney, NSW">     
<input type="button" value="Encode"  önclick="codeAddress()"> 
<input type = "text" id="count" size="5">  
</div> 
</body>
</html>

推荐答案


这篇关于每次我使用地理编码API时如何在文本框中显示计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 05:44