$(function() { $(document) .on("click","#add-data",function () { var count = $(this).data('count'); $("
").insertBefore($(this)) count+=1; $(this).data('count', count); }); $(document) .on( 'click', '.delete-day-item', function() { var count = $("#add-data").data('count'); $(this) .parent() .remove(); count-=1; $("#add-data").data('count', count); } ); $(document).on('blur', '#shoplang-2-address', function () { var address = $("#shoplang-2-address").val() + " "+$("#select2-w2-container").text(); console.log(address); geocoder.geocode( { 'address': address}, function(results, status) { console.log(status); if (status == google.maps.GeocoderStatus.OK) { $("#lat").val(results[0].geometry.location.lat()); $("#lng").val(results[0].geometry.location.lng()); var marker = AddMarker(); marker.setMap(map); map.setCenter(marker.getPosition()); } else { alert("Geocode was not successful for the following reason: " + status); } }); }); var lat, lng; if ($("#lat").val() !== "" && $("#lng").val() !== ""){ lat = $("#lat").val(); lng = $("#lng").val(); }else{ lat = '50.435'; lng = '30.60'; } console.log(lat); console.log(lng); var start_position = new google.maps.LatLng(lat, lng); var styles = [ { stylers: [ {saturation: -100} ] } ]; var settings = { styles: styles, zoom: 12, scrollwheel: false, center: start_position, mapTypeControl: true, mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, navigationControl: false, navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, scaleControl: true, streetViewControl: true, rotateControl: true, zoomControl: true, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), settings); if ($("#lat").val() !== "" && $("#lng").val() !== ""){ var marker = AddMarker(); marker.setMap(map); } var geocoder = new google.maps.Geocoder(); function AddMarker(){ var newLat = $("#lat").val(); var newLng = $("#lng").val(); var coords = new google.maps.LatLng(newLat, newLng); var marker = new google.maps.Marker({ position: coords }); return marker; } });