Email

Enter email address to share routing
 

OR
Enter phone number to share routing


×

Settings

Miles
Kilometers

Set filter

Categories
Parking Space
Weight Station
CDL Physical
DOT Drug
Parking(C)
Walmart
Speed Co
Fuel Markers

Set filter

Truck/Trailer Details
Yes
No
Driver Details
Yes
No
SOLO
TEAM
Rate Info
Calculating route
Show route (0 parkings)
Calculating route
var waypts = []; markersRouteAPI = []; var names=[]; var checkboxArray = document.getElementById('pickup_location'); waypts.push({ location: checkboxArray.value, stopover: true }); $(".search_destination_container .extra_delivery_points").each(function(){ waypts.push({ location: $(this).val(), stopover: true }); }); directionsDisplay.setPanel(document.getElementById("directions_panel")); /* var start = '37.7683909618184, -122.51089453697205'; var end = '41.850033, -87.6500523'; var request = { origin:start, destination:end, travelMode: google.maps.DirectionsTravelMode.DRIVING }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); var myRoute = response.routes[0]; var txtDir = ''; for (var i=0; i"; } document.getElementById('directions').innerHTML = txtDir; } });*/ directionsService.route({ origin: document.getElementById('current_location').value, destination: document.getElementById('delivery_location').value, waypoints: waypts, optimizeWaypoints: false, travelMode: 'DRIVING', unitSystem: google.maps.DirectionsUnitSystem.IMPERIAL }, function(response, status) { if (status === 'OK') { directionsDisplay.setDirections(response); var polyline1 = new google.maps.Polyline({ path: [], strokeColor: '#FF0000', strokeWeight: 3 }); triangleCoords = []; var directionResult = response; var myRoute = directionResult.routes[0]; //.legs[0]; var totalDistance = 0; var totalDuration = 0; if (myRoute.legs != null) { for (var i = 0; i < myRoute.legs.length; i++) { //markersRouteAPI[myRoute.legs[i].start_address] = []; //markersRouteAPI[myRoute.legs[i].start_address].push([myRoute.legs[i].start_address, myRoute.legs[i].start_location.lat(), myRoute.legs[i].start_location.lng()]); //markersRouteAPI[myRoute.legs[i].end_address] = []; //markersRouteAPI[myRoute.legs[i].end_address].push([myRoute.legs[i].end_address, myRoute.legs[i].end_location.lat(), myRoute.legs[i].end_location.lng()]); if(i == 0) { markersRouteAPI.push([myRoute.legs[i].start_address, myRoute.legs[i].start_location.lat(), myRoute.legs[i].start_location.lng()]); markersRouteAPI.push([myRoute.legs[i].end_address, myRoute.legs[i].end_location.lat(), myRoute.legs[i].end_location.lng()]); } else { markersRouteAPI.push([myRoute.legs[i].end_address, myRoute.legs[i].end_location.lat(), myRoute.legs[i].end_location.lng()]); } //markersRouteAPI[myRoute.legs[i].end_address] = myRoute.legs[i].end_location; if (myRoute.legs[i].steps != null){ for (var j = 0; j < myRoute.legs[i].steps.length; j++) { let polyline = polyline_decode(myRoute.legs[i].steps[j].polyline.points); var nextSegment = myRoute.legs[i].steps[j].path; for (var k = 0; k < polyline.length; k++) { triangleCoords.push({lat: polyline[k].latitude, lng: polyline[k].longitude}); } for (l=0;l var cascadiaFault = new google.maps.Polyline({ path: triangleCoords }); cascadiaFault.setMap(null); //markerCluster.clearMarkers(); var bounds = new google.maps.LatLngBounds( response.routes[0].legs[1].start_location, response.routes[0].legs[1].end_location); var j= 1; Activemarkers = []; $m=1; topFiveLocation=[]; topFiveLocationDist=[]; $('#tbl_top_5_locations_body').html(null); $('#tbl_top_5_locations_body_nears').html(null); var flags = [], output = [], l = markersRouteAPI.length, i; var o=1; for( i=0; i if (google.maps.geometry.poly.isLocationOnEdge(markersAPI[i].getPosition(), cascadiaFault, 0.01) == true) { if((markersAPI[i].icon.url == 'fuel.png' || markersAPI[i].icon.url == 'ta.png' || markersAPI[i].icon.url == 'PFJ.png' || markersAPI[i].icon.url == 'love.png'|| markersAPI[i].icon.url == 'SappBros.png' || markersAPI[i].icon.url == 'ambest.png')) { if(markersAPI[i].icon.url == 'love.png' ) { if(LocationArray.indexOf('LOVES') == '-1'){ markersAPI[i].setMap(map); markersAPI[i].setVisible(false); continue; } } if(markersAPI[i].icon.url == 'ta.png' ) { if(LocationArray.indexOf('TA') == '-1'){ markersAPI[i].setMap(map); markersAPI[i].setVisible(false); continue; } } if(markersAPI[i].icon.url == 'PFJ.png' ) { if(LocationArray.indexOf('PILOT') == '-1'){ markersAPI[i].setMap(map); markersAPI[i].setVisible(false); continue; } } if(markersAPI[i].icon.url == 'SappBros.png' ) { if(LocationArray.indexOf('SAPP') == '-1'){ markersAPI[i].setMap(map); markersAPI[i].setVisible(false); continue; } } if(markersAPI[i].icon.url == 'ambest.png' ) { if(LocationArray.indexOf('AMBEST') == '-1'){ markersAPI[i].setMap(map); markersAPI[i].setVisible(false); continue; } } var lat_current1 = latlng_current.lat(); var lng_current1 = latlng_current.lng(); var distmiles=distancemiles(lat_current1,lng_current1,markersAPI[i].position.lat(),markersAPI[i].position.lng()); Lblcontant = markersAPI[i].labelContent.split('-'); lblPrice=''; if (typeof Lblcontant[1] !== 'undefined'){ lblPrice=Lblcontant[1]; } lblPrice = parseFloat(lblPrice).toFixed(3); var radius_selected = parseInt($.trim($("#radius").val()) * 1609); var _kCord = new google.maps.LatLng(markersAPI[i].position.lat(), markersAPI[i].position.lng()); var _pCord = new google.maps.LatLng(lat_current1, lng_current1); if (google.maps.geometry.spherical.computeDistanceBetween(_kCord, _pCord) <= radius_selected) { if(topFiveLocationDist.length <= 8) { pdist='

'+ markersAPI[i].TYPE +' - '+ markersAPI[i].Store + '
' + markersAPI[i].address +'

'; trdist=''+pdist+''+'#'+j+' - '+lblPrice+''; $('#tbl_top_5_locations_body_nears').append(trdist); topFiveLocationDist.push(markersAPI[i]); } } if(topFiveLocation.length <= 8) { p='

'+ markersAPI[i].TYPE +' - '+ markersAPI[i].Store + '
' + markersAPI[i].address +'

'; tr=''+p+''+'#'+j+' - '+lblPrice+''; $('#tbl_top_5_locations_body').append(tr); topFiveLocation[j]=markersAPI[i]; } markersAPI[i].set('labelContent', '#'+j+' - '+lblPrice); markersAPI[i].setMap(map); markersAPI[i].setVisible(true); Activemarkers.push(markersAPI[i]); j++; } else{ if(markersAPI[i].icon.url == 'icons8-truck-stop-parking-lot-48.png') { if($(".filter-category .filter-collection__filter-item").hasClass('isactive') ){ markersAPI[i].setVisible(true); }else{ markersAPI[i].setVisible(false); } } if((markersAPI[i].icon.url == 'icons8-weight-station-48.png')) { if($(".filter-category .filter-collection__filter-weight-station").hasClass('isactive') ){ markersAPI[i].setVisible(true); }else{ markersAPI[i].setVisible(false); } } if((markersAPI[i].icon.url == 'TPR.png')) { if($(".filter-category .filter-collection__filter-item").hasClass('isactive') ){ markersAPI[i].setVisible(true); }else{ markersAPI[i].setVisible(false); } } if((markersAPI[i].icon.url == 'icons8-casino-48.png')) { if($(".filter-category .filter-collection__filter-casino-item").hasClass('isactive') ){ markersAPI[i].setVisible(true); }else{ markersAPI[i].setVisible(false); } } if((markersAPI[i].icon.url == 'icons8-heart-health-48.png')) { if($(".filter-category .filter-collection__filter-cdl-physical").hasClass('isactive') ){ markersAPI[i].setVisible(true); }else{ markersAPI[i].setVisible(false); } } if((markersAPI[i].icon.url == 'icons8-dot-48.png')) { if($(".filter-category .filter-collection__filter-dot-drug").hasClass('isactive') ){ markersAPI[i].setVisible(true); }else{ markersAPI[i].setVisible(false); } } if(markersAPI[i].icon.url == 'icons8-walmart-48.png') { if($(".filter-category .filter-collection__filter-walmart").hasClass('isactive') ){ markersAPI[i].setVisible(true); }else{ markersAPI[i].setVisible(false); } } if(markersAPI[i].icon.url == 'icons8-lovespeedco-48.png') { //console.log(markersAPI[i].icon.url+"++++-----++++"+"icons8-lovespeedco-48-active.png"); if($(".filter-category .filter-collection__filter-lovespeedco-item").hasClass('isactive') ){ // console.log(markersAPI[i].icon.url+"++++-----++++"+"icons8-lovespeedco-48-active.png"); markersAPI[i].setVisible(true); }else{ markersAPI[i].setVisible(false); } } markersAPI[i].set('labelContent', ''); markersAPI[i].setMap(map); Activemarkers.push(markersAPI[i]); } }else{ markersAPI[i].setMap(null); } } } directionsDisplay.setDirections(response); var trafficLayer = new google.maps.TrafficLayer(); trafficLayer.setMap(map); var route = response.routes[0]; /*var summaryPanel = document.getElementById('directions_panel'); summaryPanel.innerHTML = ''; for (var i = 0; i < route.legs.length; i++) { var routeSegment = i + 1; summaryPanel.innerHTML += 'Route Segment: ' + routeSegment + '
'; summaryPanel.innerHTML += route.legs[i].start_address + ' to '; summaryPanel.innerHTML += route.legs[i].end_address + '
'; summaryPanel.innerHTML += route.legs[i].distance.text + '

'; }*/ $(".main__parkings-region").show(); $(".main__parkings-region .parkings").addClass('parkings--stretched'); $(".main__parkings-region .parkings").addClass('has-suggested-parkings'); $(".parkings__scroll-container").css("max-height", window.innerHeight - 950 + "px"); computeTotalDistance(response); directionsDisplay.setMap(map); directionsDisplay.setOptions( { suppressMarkers: true } ); var my_route = response.routes[0]; for (var i = 0; i < my_route.legs.length; i++) { //addDraggableDirectionsMarker(my_route.legs[i].start_location, i+1, map, markers, directionsService, directionsDisplay); // var infocontent=my_route.legs[i].start_address; makeMarker(my_route.legs[i].start_location, icons.start, my_route.legs[i].start_address, map); } // var infocontent=my_route.legs[i].start_address; makeMarker(my_route.legs[i-1].end_location, icons.end, my_route.legs[i-1].end_address, map); } else { window.alert('Directions request failed due to ' + status); $(".map-page-loader").hide(); } }); } if (!google.maps.Polygon.prototype.getBounds){ google.maps.Polygon.prototype.getBounds = function() { var bounds = new google.maps.LatLngBounds(); var paths = this.getPaths(); for (var i = 0; i < paths.getLength(); i++) { var path = paths.getAt(i); for (var j = 0; j < path.getLength(); j++) { bounds.extend(path.getAt(j)); } } return bounds; } } var icons = { start: new google.maps.MarkerImage( // URL 'https://admin.drivercheckcall.com/www/DCCIcons/tred.png', // (width,height) new google.maps.Size(49, 60), // The origin point (x,y) new google.maps.Point(0, 0), // The anchor point (x,y) new google.maps.Point(24, 60)), end: new google.maps.MarkerImage( // URL 'https://admin.drivercheckcall.com/www/DCCIcons/torange.png', // (width,height) new google.maps.Size(49, 60), // The origin point (x,y) new google.maps.Point(0, 0), // The anchor point (x,y) new google.maps.Point(22, 32)) }; function makeMarker(position, icon, title, map) { var api_key = 'bAi7rOqWKVpdYitLLUyY'; var api_code = 'x1-ynfN4WH73Cid2igSC2w'; if(title != "Rest/Break Place") { var url1 = 'https://weather.cit.api.here.com/weather/1.0/report.json?product=observation&name='+title+'&app_id=' + api_key + '&app_code='+api_code; $.ajax({ url: url1, type: 'GET', success: function(result){ //var w1=JSON.parse(result); var myweather=result.observations.location[0].observation[0]; var temp1=(myweather.temperature * 9/5) + 32; var infocontent=temp1.toFixed(2)+'°F ('+myweather.temperatureDesc+') '; var marker1 = new google.maps.Marker({ position: position, map: map, icon: icon, title: title, clickable: true }); marker1.info = new google.maps.InfoWindow({ content: ''+title+' : '+infocontent+'' }); google.maps.event.addListener(marker1, 'click', function() { marker1.info.open(map, marker1); }); markersAPI.push(marker1); } }); }else{ var marker1 = new google.maps.Marker({ position: position, map: map, icon: icon, title: title, clickable: true }); marker1.info = new google.maps.InfoWindow({ content: ''+title+'' }); google.maps.event.addListener(marker1, 'click', function() { marker1.info.open(map, marker1); }); markersAPI.push(marker1); } } function showAllMarkers(){ // for (i = 0; i < markers.length; i++) {markers[i].setMap(map); } } function showAllFuelMarkers(obj){ for(var i=0;iTotal time is: " + (totalTime / 60 / 60).toFixed(2) + " hours"; document.getElementById('total_miles').value = parseFloat(totalDist * 0.621371).toFixed(2); showAjaxTable(); } function polyline_decode(encoded){ var points = []; var index = 0, len = encoded.length; var lat = 0, lng = 0; while (index < len) { var b, shift = 0, result = 0; do { b = encoded.charAt(index++).charCodeAt(0) - 63; result |= (b & 0x1f) << shift; shift += 5; } while (b >= 0x20); var dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1)); lat += dlat; shift = 0; result = 0; do { b = encoded.charAt(index++).charCodeAt(0) - 63; result |= (b & 0x1f) << shift; shift += 5; } while (b >= 0x20); var dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1)); lng += dlng; points.push({latitude:(lat / 1E5), longitude:(lng / 1E5)}) } return points } function showAjaxTable(){ if ($('#miles_pickup') != ""){ } var data_form = $('#fuel_form').serialize(); var current_location = $("#current_location").val(); var pickup_location = $("#pickup_location").val(); var delivery_location = $("#delivery_location").val(); var lat_current = latlng_current.lat(); var lng_current = latlng_current.lng(); var lat_pickup = latlng_pickup.lat(); var lng_pickup = latlng_pickup.lng(); var lat_delivery = latlng_delivery.lat(); var lng_delivery = latlng_delivery.lng(); var truck_id = $("#truck_id").val(); var driver_id = $("#driver_id").val(); var effective_date = $("#effective_date").val(); var id="428"; var len_extra_point = $('.search_destination_container .extra_delivery_points').length; var params = '&delivery_location='+delivery_location+'&pickup_location='+pickup_location+'¤t_location='+current_location+'&lat_current=' + lat_current + '&lng_current=' + lng_current + '&lat_pickup=' + lat_pickup + '&lng_pickup=' + lng_pickup + '&lat_delivery=' + lat_delivery + '&lng_delivery=' + lng_delivery + '&delivery_state=' + delivery_state + '¤t_state=' + current_state + '&pickup_state=' + pickup_state + '&len='+len_extra_point + '&truck_id=' + truck_id + '&driver_id=' + driver_id + '&effective_date=' + effective_date +'&id='+id; var z= 0; $(".search_destination_container .extra_delivery_points").each(function(){ //params+='&extra_delivery_points[]='+$(this).val(); /* edited code */ extraId=$(this).data("id") var str = $(this).val().split(","); count = str.length; pickup_extra = str[count - 2]; params+='&extra_delivery_points_lat[]='+$("#add_delivery_location_lat"+extraId).val()+'&extra_delivery_points_lng[]='+$("#add_delivery_location_lng"+extraId).val()+'&extra_delivery_points[]='+$(this).val()+'&extra_points'+z+'='+pickup_extra; z++; /* edited code */ }); $(".fuel_locations:checked").each(function(){ /* edited code */ params+='&chain[]='+$(this).val(); /* edited code */ }); var data = data_form + params; // $.ajax({ // url: "https://aitrans.co/pricing2/route/print-fueltable.php", // type: 'POST', // data, // success: function(result){ // $("#print_fule_table").html(result); // } // }); // $.ajax({ // url: "https://aitrans.co/pricing2/route/fueltable2.php", // type: 'POST', // data, // success: function(result){ // $("#fule_table").html(result); // $.ajax({ // url: "https://aitrans.co/pricing2/route/getrouteid.php", // type: 'GET', // success:function(resDataNew){ // history.replaceState(null, document.querySelector("title").innerText, window.location.pathname+"?id="+resDataNew); // $("#sharing_link").val(window.location.pathname+"?id="+resDataNew); // } // }); //alert(result); //if (result != ''){ var current_gallons = parseInt($('#current_gallons').html()); var place = autocomplete_current.getPlace(); if(typeof place!="undefined"){ if (!place.geometry) { window.alert("No details available for input: '" + place.name + "'"); return; } } var radius_selected = parseInt($.trim($("#radius").val()) * 1609); var a = $.trim($("#hos_miles").html()); calcpay = a.toString().split(".")[0] var brokerpay = parseInt(calcpay * 1609); var fuel_tank = parseFloat($.trim($("#fule_tank_radius").html()) * 1609); if(typeof place!="undefined"){ marker.setPosition(place.geometry.location); } else { myLatlng = new google.maps.LatLng(latlng_current.lat(),latlng_current.lng()); marker.setPosition(myLatlng); } //console.log(latlng_current.lat()); var circle = new google.maps.Circle({ map: map, radius: radius_selected, fillColor: '#013220', //green fillOpacity: 0.3, strokeColor: "#000", strokeWeight: 4 }); circle.bindTo('center', marker, 'position'); var circle1 = new google.maps.Circle({ map: map, radius: fuel_tank, fillColor: '#ff8c00', //orange fillOpacity: 0.5, strokeColor: "#FFF", strokeWeight: 2 }); circle1.bindTo('center', marker, 'position'); var circle2 = new google.maps.Circle({ map: map, radius: brokerpay, fillColor: '#FF6600', //red fillOpacity: 0.5, strokeColor: "#FFF", strokeWeight: 1 }); // circle2.bindTo('center', marker, 'position'); //} //} //}); } $(".zoom-buttons__zoom-in").click(function(){ map.setZoom(map.getZoom() + 1); }); $(".zoom-buttons__zoom-out").click(function(){ map.setZoom(map.getZoom() - 1); }); $(".bottom-buttons__satellite-map").click(function(){ $(this).toggleClass("-active"); var maptype = map.getMapTypeId(); if (map.getMapTypeId() != google.maps.MapTypeId.SATELLITE) { map.setMapTypeId(google.maps.MapTypeId.SATELLITE) }else{ map.setMapTypeId(google.maps.MapTypeId.ROADMAP) } }); // function handleLocationError(browserHasGeolocation, infoWindow, pos) { // } $(".bottom-buttons__current-location-button").click(function(){ // Try HTML5 geolocation. if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { console.log(position.coords.latitude); console.log(position.coords.longitude); var pos = { lat: position.coords.latitude, lng: position.coords.longitude, }; codeLatLng(position.coords.latitude, position.coords.longitude) map.setCenter(pos); map.setZoom( 8 ); }, function() { // handleLocationError(true, infoWindow, map.getCenter()); }); } else { // Browser doesn't support Geolocation // handleLocationError(false, infoWindow, map.getCenter()); } }); function codeLatLng(lat, lng) { var latlng = new google.maps.LatLng(lat, lng); var geocoder= new google.maps.Geocoder(); geocoder.geocode({'latLng': latlng}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { console.log(results) if (results[1]) { //formatted address // console.log(results[0].address_components); var city1 = results[0].address_components[5]; var state1 = results[0].address_components[6]; var country = results[0].address_components[7]; var value1 = city1.long_name+' '+state1.short_name+','+country.long_name; $('#current_location').val(value1); // console.log(results[0].address_components); //console.log(results[0].formatted_address); // alert(results[0].formatted_address) //find country name for (var i=0; i var form = $('#print_fule_table'), cache_width = form.width(), a4 = [595.28, 841.89]; // for a4 size paper width and height $('.parkings__print-button').on('click', function () { $('body').scrollTop(0); createPDF(); }); //create pdf function createPDF() { getCanvas().then(function (canvas) { var img = canvas.toDataURL("image/png"), doc = new jsPDF({ unit: 'px', format: 'a4' }); doc.addImage(img, 'JPEG', 20, 20); doc.saveToFile('AIFuel-optimizer.pdf'); form.width(cache_width); }); } // create canvas object function getCanvas() { form.width((a4[0] * 1.33333) - 80).css('max-width', 'none'); return html2canvas(form, { imageTimeout: 2000, removeContainer: true }); } function sendMail(){ var email_address = $('#sharing_link_email').val(); if(email_address != ''){ var lat_current = latlng_current.lat(); var lng_current = latlng_current.lng(); var lat_pickup = latlng_pickup.lat(); var lng_pickup = latlng_pickup.lng(); var lat_delivery = latlng_delivery.lat(); var lng_delivery = latlng_delivery.lng(); var truck_id = $("#truck_id").val(); var driver_id = $("#driver_id").val(); var effective_date = $("#effective_date").val(); var id="428"; var len_extra_point = $('.search_destination_container .extra_delivery_points').length; var params = '&delivery_location='+delivery_location+'&pickup_location='+pickup_location+'¤t_location='+current_location+'&lat_current=' + lat_current + '&lng_current=' + lng_current + '&lat_pickup=' + lat_pickup + '&lng_pickup=' + lng_pickup + '&lat_delivery=' + lat_delivery + '&lng_delivery=' + lng_delivery + '&delivery_state=' + delivery_state + '¤t_state=' + current_state + '&pickup_state=' + pickup_state + '&len='+len_extra_point + '&truck_id=' + truck_id + '&driver_id=' + driver_id + '&effective_date=' + effective_date +'&id='+id; var z= 0; $(".search_destination_container .extra_delivery_points").each(function(){ /* edited code */ extraId=$(this).data("id") var str = $(this).val().split(","); count = str.length; pickup_extra = str[count - 2]; params+='&extra_delivery_points_lat[]='+$("#add_delivery_location_lat"+extraId).val()+'&extra_delivery_points_lng[]='+$("#add_delivery_location_lng"+extraId).val()+'&extra_delivery_points[]='+$(this).val()+'&extra_points'+z+'='+pickup_extra; z++; /* edited code */ }); top5html=escape($('#tbl_top_5_locations_body_nears').html()); top5Nearhtml=escape($('#tbl_top_5_locations_body').html()); getCanvas().then(function (canvas) { var img = canvas.toDataURL("image/png"); $.ajax({ url:"http://portal2.aitrans.co/sendroutemail.php?"+params, type:"post", data:{img:img,email:$("#sharing_link_email").val(),link:$("#sharing_link").val(),top5html:top5html,top5Nearhtml:top5Nearhtml}, success:function(){ $(".tmscloud-sharing-btn-close").click(); alert("Email send successfully"); } }); }); var PDF='AIFuel-optimizer.pdf' }else { alert('Please Enter Email Address'); } } /* edited code */ var addedIndexd = 0; $(".add_delivery_address_btn").click(function(){ addedIndexd = 0; if($(".extra_delivery_points").length > 0){ addedIndexd = parseInt($(".extra_delivery_points:last").data("id")) + 1; } var totalAddress = $(".search_destination_container > div").length; var htmlTemplate = '
'; htmlTemplate += ''; htmlTemplate += '--> rer