jQuery.getScript( "https://maps.googleapis.com/maps/api/js?key=AIzaSyC8tawHQNfifKWkVGN3RhJtqB12JUvjYrU&sensor=false&libraries=places&callback=initialize", function( data, textStatus, jqxhr ) { console.log( "Load was performed." ); });
var placeSearch, autocomplete;
var componentForm = {
street_number: 'short_name',
route: 'long_name',
locality: 'long_name',
administrative_area_level_1: 'short_name',
country: 'long_name',
postal_code: 'short_name'
};
function initialize() {
autocomplete = new google.maps.places.Autocomplete(
(document.getElementById('autocomplete')), {
types: ['geocode']
});
google.maps.event.addListener(autocomplete, 'place_changed', function () {
fillInAddress();
});
}
function initAutocomplete() {
autocomplete = new google.maps.places.Autocomplete(
document.getElementById('autocomplete'), {types: ['geocode']});
autocomplete.setFields(['address_component']);
autocomplete.addListener('place_changed', fillInAddress);
}
function fillInAddress() {
var place = autocomplete.getPlace();
for (var component in componentForm) {
document.getElementById(component).value = '';
document.getElementById(component).disabled = false;
}
for (var i = 0; i < place.address_components.length; i++) {
var addressType = place.address_components[i].types[0];
if (componentForm[addressType]) {
var val = place.address_components[i][componentForm[addressType]];
document.getElementById(addressType).value = val;
}
}
}
function geolocate() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var geolocation = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
var circle = new google.maps.Circle(
{center: geolocation, radius: position.coords.accuracy});
autocomplete.setBounds(circle.getBounds());
});
}
}
jQuery.getScript( "https://trustyourmove.com/asset/plugins/gmap/jquery.geocomplete_api_new.js", function( data, textStatus, jqxhr ) {
jQuery(function (){
var movingItem = '', movingUrl = '';
jQuery('#selectMoving').attr('data-href', 'https://api.trustyourmove.com/home_removal');jQuery('form#removeapiform').attr('action', 'https://api.trustyourmove.com/home_removal');jQuery('form#removeapiform #subscriber').val('steve_wood_removals_ltd');jQuery('form#removeapiform #token').val('YRdKiZOdA11Mnv8Pp1AVlJLXjomyl6CkYP4gPStqUuch0l7pmI');jQuery('form#removeapiform #type_id').val('1655'); jQuery('#removelid').html('');
jQuery('#removelid').on('change', function(){ movingItem = jQuery(this).val(); movingUrl = jQuery('#removelid option:selected').data('href'); jQuery('#selectMoving').val(movingItem); jQuery('#selectMoving').attr('data-href',movingUrl);jQuery('form#removeapiform').attr('action', movingUrl); });
jQuery("#removalStart").geocomplete({ details: "#geofrom", detailsAttribute: "data-geo"});
var toCheck = jQuery('#geoto').val();
jQuery('#removalStart').on('change', function(){ if(toCheck === ''){ var p1 = jQuery('#removalStart').val(); jQuery('#removalEnd').val(p1); }});
jQuery("#removalEnd").geocomplete({ details: "#geoto", detailsAttribute: "data-geo" });
jQuery("#Quotebtn").click(function () { var distance = jQuery('#removaldistance').val(), from = jQuery('#removalStart').val(), to = jQuery('#removalEnd').val(), rem = jQuery('#selectMoving').val(),frominp = jQuery('#postcode1').val(), toinp = jQuery('#postcode2').val();
if (from !== '' && to !== '' && rem !== '') { if (!isNaN(frominp)) { jQuery('#postcode1').val(from); } if (!isNaN(toinp)) { jQuery('#postcode2').val(to);} }
if (frominp !== '' && toinp !== '' && distance !== '') {
if(distance <= 0){
jQuery('#error').html('Removal distance too short.');
setTimeout(function(){
jQuery('.text-error').remove();
},300);
}
jQuery('#Quotebtn').html('Processing..');
}else{
jQuery('#error').html('Location not found.');
setTimeout(function(){
jQuery('.text-error').remove();
jQuery("#Quotebtn").click();
},3000);
return false;
}
});
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
});
});