i want to refresh my maps when user set lat and long in input box. but when users sets another lat, the maps still show the first one.
<script type="text/javascript">
$(document).ready(function(){
$(document).on("click", "#generate", function() {
var Lattitude = $('#Lattitude').val();
var Longitude = $('#Longitude').val();
google.maps.event.trigger(('#map_canvas'), 'resize'); //is it right code to refresh my map?
var map = $('#map_canvas').gmap().bind('init', function(ev, map) {
if (Lattitude == "" || Longitude=="") {
var address = $('#merchantAddress').val();
var key = '...';
var url = 'https://maps.googleapis.com/maps/api/geocode/json?address='+address+'&key='+key;
$.get(url, function( results ) {
if (results.status == 'OK') {
Lattitude = results.geometry.location.lat;
Longitude = results.geometry.location.lng;
$('#map_canvas').gmap('addMarker', {'position': Lattitude+','+Longitude, 'bounds': true, 'zoom':5}).click(function() {
$('#map_canvas').gmap('openInfoWindow', {'content': 'Your Location'}, this);
});
}else{
alert (results.status);
}
});
}else{
$('#map_canvas').gmap('addMarker', {'position': Lattitude+','+Longitude, 'bounds': true}).click(function() {
$('#map_canvas').gmap('openInfoWindow', {'content': 'Your Location'}, this);
});
}
});
$('#map_canvas').removeClass("hide");
});
});
</script>