hello,
i am using this google api so user can select city and country, it works fine.
i want on page load by default it gets user city and country and bind to textbox then user can change if needed please advice
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places&sensor=false&key=AIzaSyBE1J5Pe_GZXBR_x9TXOv6TU5vtCSmEPW4"></script>
<script type="text/javascript">
$(function () {
var textbox1 = $(this).find('[id*=TextBox2]');
ApplyAutoComplete(textbox1);
});
function ApplyAutoComplete(input) {
google.maps.event.addDomListener(window, 'load', function () {
var places;
for (var i = 0; i < input.length; i++) {
var options = { types: ['(cities)'] };
places = new google.maps.places.Autocomplete(input[i], options);
}
google.maps.event.addListener(places, 'place_changed', function () {
var place = places.getPlace();
var address = place.formatted_address;
var mesg = "Address: " + address;
});
});
}
var source, destination;
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
function initialize(textBox) {
var input = textBox;
var options = {
types: ['(cities)']
// Uncomment if restrict for Country.
//, componentRestrictions: { country: 'in' }
};
var autocomplete = new google.maps.places.Autocomplete(input, options);
}
google.maps.event.addDomListener(window, 'load', function () {
initialize(document.getElementById('<%=TextBox2.ClientID%>'));
directionsDisplay = new google.maps.DirectionsRenderer({ 'draggable': true });
})
</script>