hello,
i have following 2 JavaScript google autocomplete
method 1 loads all country
<script type="text/javascript">
google.maps.event.addDomListener(window, 'load', function () {
var options = { types: ['(cities)'], componentRestrictions: { country: ["KE"]} };
var places = new google.maps.places.Autocomplete(document.getElementById('<%=txtaddress.ClientID%>'));
google.maps.event.addListener(places, 'place_changed', function () {
var place = places.getPlace();
var address = place.formatted_address;
var latitude = place.geometry.location.lat();
var longitude = place.geometry.location.lng();
var mesg = "Address: " + address;
mesg += "\nLatitude: " + latitude;
mesg += "\nLongitude: " + longitude;
//alert(mesg);
});
});
</script>
method 2 load specific country
<script type="text/javascript">
google.maps.event.addDomListener(window, 'load', function () {
var options = { types: ['(cities)'], componentRestrictions: { country: ["KE"]} };
var places = new google.maps.places.Autocomplete(document.getElementById('<%=txtaddress.ClientID%>', options));
google.maps.event.addListener(places, 'place_changed', function () {
var place = places.getPlace();
var address = place.formatted_address;
var latitude = place.geometry.location.lat();
var longitude = place.geometry.location.lng();
var mesg = "Address: " + address;
mesg += "\nLatitude: " + latitude;
mesg += "\nLongitude: " + longitude;
//alert(mesg);
});
});
</script>
i am using it on my page, i want to shift it to JavScript file in folder then call it conditionally on page.
<asp:Label ID="lblerror" ForeColor="Red" runat="server" Text=""></asp:Label>
if lblerror value is "All" so call all contry method if lblerror value is "country" so call specific country method
Please advice