Click here to Skip to main content
15,881,712 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
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>
Posted

1 solution

Steven.Pinto - 1 hr ago
Create a new google map api key from here http://code.google.com/apis/maps/signup.html n the change the sensor=true n add the whole script block on the page n then check
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900