EOS/Scripts/out/files/Inventory_ShowDealerVanDetail.js.html
Nidhi Bhargava f0c1ab20e1 code push
2025-09-04 16:25:07 +05:30

1261 lines
55 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Inventory\ShowDealerVanDetail.js</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
<script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
</head>
<body class="yui3-skin-sam">
<div id="doc">
<div id="hd" class="yui3-g header">
<div class="yui3-u-3-4">
<h1><img src="../assets/css/logo.png" title=""></h1>
</div>
<div class="yui3-u-1-4 version">
<em>API Docs for: </em>
</div>
</div>
<div id="bd" class="yui3-g">
<div class="yui3-u-1-4">
<div id="docs-sidebar" class="sidebar apidocs">
<div id="api-list">
<h2 class="off-left">APIs</h2>
<div id="api-tabview" class="tabview">
<ul class="tabs">
<li><a href="#api-classes">Classes</a></li>
<li><a href="#api-modules">Modules</a></li>
</ul>
<div id="api-tabview-filter">
<input type="search" id="api-filter" placeholder="Type to filter APIs">
</div>
<div id="api-tabview-panel">
<ul id="api-classes" class="apis classes">
<li><a href="../classes/CallFeedbackRating.html">CallFeedbackRating</a></li>
<li><a href="../classes/CloseTicketReport.html">CloseTicketReport</a></li>
<li><a href="../classes/ConsolidatedReport.html">ConsolidatedReport</a></li>
<li><a href="../classes/CustomerReport.html">CustomerReport</a></li>
<li><a href="../classes/DealerWiseCallDetails.html">DealerWiseCallDetails</a></li>
<li><a href="../classes/DeclinedCalls.html">DeclinedCalls</a></li>
<li><a href="../classes/DropDownData.html">DropDownData</a></li>
<li><a href="../classes/EicherPromise.html">EicherPromise</a></li>
<li><a href="../classes/EosCallCount.html">EosCallCount</a></li>
<li><a href="../classes/GeoAnalysis.html">GeoAnalysis</a></li>
<li><a href="../classes/HdBusLmdContrCallFeedbackRatingibution.html">HdBusLmdContrCallFeedbackRatingibution</a></li>
<li><a href="../classes/HdBusLmdContribution.html">HdBusLmdContribution</a></li>
<li><a href="../classes/HistoryTracking.html">HistoryTracking</a></li>
<li><a href="../classes/LiveTracking.html">LiveTracking</a></li>
<li><a href="../classes/ManageEscalation.html">ManageEscalation</a></li>
<li><a href="../classes/ManageFleet.html">ManageFleet</a></li>
<li><a href="../classes/ManageFleet_Detail.html">ManageFleet_Detail</a></li>
<li><a href="../classes/ManageFleet_details.html">ManageFleet_details</a></li>
<li><a href="../classes/ManageOwner.html">ManageOwner</a></li>
<li><a href="../classes/ManageReason.html">ManageReason</a></li>
<li><a href="../classes/ManageVechile.html">ManageVechile</a></li>
<li><a href="../classes/ManageVehicle.html">ManageVehicle</a></li>
<li><a href="../classes/NonVecvUserManagement.html">NonVecvUserManagement</a></li>
<li><a href="../classes/Notifications.html">Notifications</a></li>
<li><a href="../classes/OpenTicketReport.html">OpenTicketReport</a></li>
<li><a href="../classes/OrganizationChart.html">OrganizationChart</a></li>
<li><a href="../classes/PositioningTool.html">PositioningTool</a></li>
<li><a href="../classes/PositioningTool_Report.html">PositioningTool_Report</a></li>
<li><a href="../classes/ReasonForClosure.html">ReasonForClosure</a></li>
<li><a href="../classes/Report.html">Report</a></li>
<li><a href="../classes/ShowDealerMap.html">ShowDealerMap</a></li>
<li><a href="../classes/TicketAdministration.html">TicketAdministration</a></li>
<li><a href="../classes/TicketAdministration_FullDetail.html">TicketAdministration_FullDetail</a></li>
<li><a href="../classes/TicketFeedback.html">TicketFeedback</a></li>
<li><a href="../classes/TicketForDealer.html">TicketForDealer</a></li>
<li><a href="../classes/TicketForDealer_FullDetails.html">TicketForDealer_FullDetails</a></li>
<li><a href="../classes/TicketReassign.html">TicketReassign</a></li>
<li><a href="../classes/TileDashboard.html">TileDashboard</a></li>
<li><a href="../classes/TimeSlotClosure.html">TimeSlotClosure</a></li>
<li><a href="../classes/TollFreeAndOpportunityLoss.html">TollFreeAndOpportunityLoss</a></li>
<li><a href="../classes/VanCoverageDesigner.html">VanCoverageDesigner</a></li>
<li><a href="../classes/VecvUserManagement.html">VecvUserManagement</a></li>
</ul>
<ul id="api-modules" class="apis modules">
<li><a href="../modules/Dashboard.html">Dashboard</a></li>
<li><a href="../modules/DropDownData.html">DropDownData</a></li>
<li><a href="../modules/Geo.html">Geo</a></li>
<li><a href="../modules/Inventory.html">Inventory</a></li>
<li><a href="../modules/Notifications.html">Notifications</a></li>
<li><a href="../modules/ReportModule.html">ReportModule</a></li>
<li><a href="../modules/Ticket.html">Ticket</a></li>
<li><a href="../modules/TrackingModule.html">TrackingModule</a></li>
<li><a href="../modules/UserManagement.html">UserManagement</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="yui3-u-3-4">
<div id="api-options">
Show:
<label for="api-show-inherited">
<input type="checkbox" id="api-show-inherited" checked>
Inherited
</label>
<label for="api-show-protected">
<input type="checkbox" id="api-show-protected">
Protected
</label>
<label for="api-show-private">
<input type="checkbox" id="api-show-private">
Private
</label>
<label for="api-show-deprecated">
<input type="checkbox" id="api-show-deprecated">
Deprecated
</label>
</div>
<div class="apidocs">
<div id="docs-main">
<div class="content">
<h1 class="file-heading">File: Inventory\ShowDealerVanDetail.js</h1>
<div class="file">
<pre class="code prettyprint linenums">
/*================================================================================================================\
+
+ Project : GODATA-VCEV
+ Filename : ShowDealerVanDetail.js
+ Module Name : Van Coverage Designer
+ Purpose : To show details of a van and design its coverage for all SLAs and save that.
+ Coded By : Pankaj Khandal
+
+================================================================================================================*/
var COVERAGE_JSON = []; // To store all the newly generated coverage
var GET_COVERAGE_JSON = []; // To store exiting coverage JSON objects
var EXISTING_COVERAGE_JSON = {}; // To store existing Coverage JSON for a Van
/**
* To show details of a van and design its coverage for all SLAs and save that.
* @module Inventory
*/
/**
* To show details of a van and design its coverage for all SLAs.
* @class VanCoverageDesigner
* @constructor
*/
//================= Global variables===============================
/**
* Global References: Initializing global stores for markers, images, icons, enable/disable bits etc.
* @for VanCoverageDesigner
*/
var map = null;
var directionService;
var geoCoder;
var distanceMatrixService;
var pointAngle = 30; // Angle on which we want a point from a sorce point (Degree)
var radiusIncrement = 15; // constant increament in radius to get optimal reachable point from a van
var radiusAccToSlaObj = { &#x27;90&#x27;: 55, &#x27;120&#x27;: 75 }; // Van&#x27;s reachable point&#x27;s minimum distance (KMs) for diffrent SLAs in minutes
var coverageMultiplier = 1.6; // coverage enhancer factor
var slaTimeInMin = 0; // to store SLA time globally
var slaId = 0; // To store SLA Id globally
var latlngbounds; // To store lat-long objects globally
var enableDiffCoverage = false; // to enable designing coverage for another SLA
var vanId = &#x27;&#x27;; // To store van id gloabally
var vanLat = 0; // To store van lay gloabally
var vanLng = 0; // To store van long globally
var allSlaCount = 0; // To store all SLA count
var isCoverageExist = false; // To check whether coveage exists or not
var coverageDesiged = false; // To check if coveage is designed or not
//-----------------------------------------------
var disable_map_click_Listener = true; // To disable map click
var disable_map_mousemove_Listener = true; // To disable changing the cursor when move to map
var enableCoverageDesign = true; // To enable the coverage design functionality
var popTheVanOut = true; // if there is any error in designig coverage, then delete the last van inserted into Van Marker list
var VAN_MARKERS = []; // To store van markers globally
var VAN_ROUTES = []; // To store van routes globally
var POLYGONS = []; // To store Polygon objects globally
var directionObj = {}; // to store Direction Objects globally
var VAN_REACHABLE_POINT = []; // To store van reachbale points objects globally.
//--------------------------------------------
//initialize marker paths
var vanImagePath = &quot;../../Content/css/images/avil-van.png&quot;,
vanReachablePointImagePath = &quot;../../Scripts/map_api/icons/red_circle.png&quot;,
markerTransImgPath = &quot;../../Scripts/map_api/icons/red_blink.gif&quot;,
vanToolImagePath = &quot;../../Content/css/images/avil-van-pointing.png&quot;,
defaultLat = 26.912285124827,
defaultLng = 75.7873203125;
//=================================================================
/////============================= Getting Circular points which is some time away from a source point =====================
/**
* To convert a degrees into radians.
* @method Number.prototype.toRad
* @for VanCoverageDesigner
*/
Number.prototype.toRad = function () {
return this * Math.PI / 180;
}
/**
* To convert a radians into degrees.
* @method Number.prototype.toDeg
* @for VanCoverageDesigner
*/
Number.prototype.toDeg = function () {
return this * 180 / Math.PI;
}
/**
* To get a position at an angle and at a distance on google map.
* @method google.maps.LatLng.prototype.destinationPoint
* @param {Number} angle angle in Degrees
* @param {Number} dist distance in KMs
* @for VanCoverageDesigner
*/
google.maps.LatLng.prototype.destinationPoint = function (angle, dist) {
dist = dist / 6371;
angle = angle.toRad();
var lat1 = this.lat().toRad(), lon1 = this.lng().toRad();
var lat2 = Math.asin(Math.sin(lat1) * Math.cos(dist) + Math.cos(lat1) * Math.sin(dist) * Math.cos(angle));
var lon2 = lon1 + Math.atan2(Math.sin(angle) * Math.sin(dist) * Math.cos(lat1), Math.cos(dist) - Math.sin(lat1) * Math.sin(lat2));
if (isNaN(lat2) || isNaN(lon2)) return null;
return new google.maps.LatLng(lat2.toDeg(), lon2.toDeg());
}
/**
* To get a position at an angle and at a distance on google map.
* @method findReachablePointsForVan
* @param {Object} sourcePosition position(lat-long object) of source
* @param {Number} pointAngle angle in Degrees
* @param {Number} radius distance in KMs
* @for VanCoverageDesigner
*/
function findReachablePointsForVan(sourcePosition, pointAngle, radius) {
var reachablePoints = [];
for (var i = 0; i &lt;= 360; i = i + pointAngle) {
var point = sourcePosition.destinationPoint(i, radius);
reachablePoints.push(point);
}
return reachablePoints;
}
/////================================================================================================================
///============== Delete/Remove Objects From Map Section Start ==============================
/**
* To delete all van reachbale points from the map
* @method deleteAllVanReachablePoint
* @for VanCoverageDesigner
*/
function deleteAllVanReachablePoint() {
for (var i = 0; i &lt; VAN_REACHABLE_POINT.length; i++) {
VAN_REACHABLE_POINT[i].setMap(null);
}
// Making the MARKERS-Array empty.
VAN_REACHABLE_POINT = [];
}
/**
* To delete all the van markers from the map
* @method deleteVanMarkers
* @for VanCoverageDesigner
*/
function deleteVanMarkers() {
for (var i = 0; i &lt; VAN_MARKERS.length; i++) {
VAN_MARKERS[i].setMap(null);
}
VAN_MARKERS = []; // Making the Global Van-Array empty.
}
/**
* To delete marker from the map based on the id
* @method deleteMarker
* @param {String} markerId id of marker
* @for VanCoverageDesigner
*/
function deleteMarker(markerId) {
for (var i = 0; i &lt; MARKERS.length; i++) {
if (MARKERS[i].id == markerId) {
MARKERS[i].setMap(null);
MARKERS.splice(i, 1);
}
}
}
/**
* To delete all polygons from the map
* @method deleteAllPolygons
* @for VanCoverageDesigner
*/
function deleteAllPolygons() {
for (var i = 0; i &lt; POLYGONS.length; i++) {
POLYGONS[i].setMap(null);
}
POLYGONS = [];
}
/**
* To delete polygon from the map based on the id
* @method deletePolygon
* @param {String} polygonId id of polygon
* @for VanCoverageDesigner
*/
function deletePolygon(polygonId) {
for (var i = 0; i &lt; POLYGONS.length; i++) {
if (POLYGONS[i].title == polygonId) {
POLYGONS[i].setMap(null);
POLYGONS.splice(i, 1);
}
}
}
/**
* To delete a route based on the id (Blind Spot)
* @method deleteRoute
* @param {String} routeId Id of route
* @for VanCoverageDesigner
*/
function deleteRoute(routeId) {
var route = directionObj[routeId];
for (var i = 0; i &lt; route.length; i++) {
route[i].setMap(null);
}
directionObj[routeId] = [];
}
/**
* To delete all routes from the map based on the id (Blind Spot)
* @method deleteAllRoutes
* @for VanCoverageDesigner
*/
function deleteAllRoutes() {
$.each(VAN_REACHABLE_POINT, function (index, marker) {
deleteRoute(marker.id);
});
directionObj = {};
}
///============== Delete/Remove Objects From Map Section End ==============================
/**
* To reset blind spots generator
* @method resetBlindSpotGenerator
* @for VanCoverageDesigner
*/
function resetVanCoverage() {
deleteVanMarkers(); // Deleting Van-Markers from the map.
deleteAllRoutes(); // Deleting all the routes from the map
deleteAllPolygons(); // Deleting all the polygons
deleteAllVanReachablePoint(); // Deleting all van reachbale points
$(&#x27;.slaBtn&#x27;).removeClass(&#x27;slaBtnSelected&#x27;); // deselect SLA Buttons
// Re-Initializing all the global variables for BlindSpot.
disable_map_click_Listener = true;
disable_map_mousemove_Listener = true;
enableCoverageDesign = true;
popTheVanOut = true;
allSlaCount = 0;
MARKERS = [];
VAN_REACHABLE_POINT = [];
COVERAGE_JSON = [];
GET_COVERAGE_JSON = [];
}
/**
* To save the generated Van Coverage
* @method saveVanCoverage
* @for VanCoverageDesigner
*/
function saveVanCoverage() {
$(&quot;#div_load&quot;).show(); // Showing loading
SecurityToken = securityToken;
// If vanId is not there, then don&#x27;t save the coverage
if (vanId == &#x27;&#x27;) {
jAlert(EOS_VAN_COVERAGE_DESIGN_MSG[&#x27;before_coverage_design_warning&#x27;], &#x27;Message&#x27;);
$(&quot;#div_load&quot;).hide(); // Hiding loading
return;
}
// If coverage for all SLAs is not designed, then don&#x27;t save the coverage at all.
if (COVERAGE_JSON.length != allSlaCount) {
jAlert(EOS_VAN_COVERAGE_DESIGN_MSG[&#x27;all_sla_coverage_design_warning&#x27;], &#x27;Message&#x27;);
$(&quot;#div_load&quot;).hide(); // Hiding loading
return;
}
var updatedVanCoverageData = JSON.stringify(COVERAGE_JSON); // serializing the JSON before sending to the server
$.ajax({
url: WCFRESTURL.GetInsertVanCoverage,
type: &quot;POST&quot;,
data: { Token: &quot;teramatrix&quot;, Operation: &#x27;insert&#x27;, VanId: vanId, VanDefaultLatitude: vanLat, VanDefaultLongitude: vanLng, CoverageJson: updatedVanCoverageData },
dataType: &quot;json&quot;,
contentType: &quot;application/x-www-form-urlencoded; charset=utf-8&quot;, // This is the content type when posting Plain Text to server.
success: function (data) {
// showing success message when coverage is designed
if (data.Status == &#x27;1&#x27;) {
jAlert(EOS_VAN_COVERAGE_DESIGN_MSG[&#x27;van_coverage_design_success&#x27;], &#x27;Message&#x27;);
}
$(&#x27;#coverageBtns&#x27;).hide();
},
complete: function () {
$(&quot;#div_load&quot;).hide(); // Hiding loading
COVERAGE_JSON = []; // Making empty the coverage design to store new coverage.
},
error: function (jqXHR, textStatus, errorThrown) {
jAlert(EOS_VAN_COVERAGE_DESIGN_MSG[&#x27;van_coverage_design_error&#x27;], &#x27;Message&#x27;);
$(&quot;#div_load&quot;).hide(); // Hiding loading
}
});
}
/**
* To get Van coverage, if exists.
* @method getExitingVanCoverage
* @param {String} van_id Id of Van
* @for VanCoverageDesigner
*/
function getExitingVanCoverage(van_id) {
SecurityToken = securityToken;
var getVanCoverageData = JSON.stringify(GET_COVERAGE_JSON); // serializing the JSON before sending to the server
$.ajax({
url: WCFRESTURL.GetInsertVanCoverage,
type: &quot;POST&quot;,
data: { Token: &quot;teramatrix&quot;, Operation: &#x27;get&#x27;, VanId: van_id, VanDefaultLatitude: &#x27;&#x27;, VanDefaultLongitude: &#x27;&#x27;, CoverageJson: getVanCoverageData },
dataType: &quot;json&quot;,
contentType: &quot;application/x-www-form-urlencoded; charset=utf-8&quot;, // This is the content type when posting Plain Text to server.
success: function (data) {
// If status is success
if (data.Status == &#x27;1&#x27;) {
// If there is no van lat-long, then show coverage buttons to design the coverage
if (data.VanDefaultLatitude === null) {
$(&#x27;#coverageBtns&#x27;).show();
}
// if coverage is there then store it globally
else {
isCoverageExist = true;
EXISTING_COVERAGE_JSON = data;
}
}
},
complete: function () {
},
error: function (jqXHR, textStatus, errorThrown) {
jAlert(EOS_VAN_COVERAGE_DESIGN_MSG[&#x27;van_coverage_not_exists&#x27;], &#x27;Message&#x27;);
}
});
}
/**
* SLA button click handler
* If there is existing van coverage available then plot that on map, else allow designing van coverage on map click.
* @method slaButtonClick
* @for VanCoverageDesigner
*/
function slaButtonClick(currBtn) {
$(&#x27;.slaBtn&#x27;).removeClass(&#x27;slaBtnSelected&#x27;); // deselecting all the SLA buttons
$(currBtn).addClass(&#x27;slaBtnSelected&#x27;); // selecting the currently clicked SLA button
slaTimeInMin = $(currBtn).val(); // stroring SLA value
slaId = $(currBtn).attr(&#x27;id&#x27;); // getting SLA Id
disable_map_click_Listener = false;
disable_map_mousemove_Listener = false;
if (isCoverageExist &amp;&amp; EXISTING_COVERAGE_JSON.VanDefaultLatitude !== null) {
deleteVanMarkers(); // Deleting Van-Markers from the map.
deleteAllRoutes(); // Deleting all the routes from the map
deleteAllPolygons(); // Deleting all the polygons
deleteAllVanReachablePoint(); // Deleting all van reachbale points
MARKERS = []; // making the markers array empty to store fresh ones.
VAN_ROUTES = []; // making the routes array empty to store fresh ones.
VAN_REACHABLE_POINT = []; // making the van reachable points array empty to store fresh ones.
var polyCoordinates = []; // to store the van reachable points to draw polygon
disable_map_click_Listener = true; // disabling map click
disable_map_mousemove_Listener = true; // disabling cursor changing on mouse move on map
vanId = $(&#x27;#vanId&#x27;).val(); // getting van id.
vanLat = EXISTING_COVERAGE_JSON.VanDefaultLatitude; // getting van latitude
vanLng = EXISTING_COVERAGE_JSON.VanDefaultLongitude; // getting van longitude
var sourceVan = new google.maps.LatLng(vanLat, vanLng); // ceating van lat-long object
// Iterating thourough the Exiting Van coverage JSOn to plot the coverage for a partcular SLA.
$.each(EXISTING_COVERAGE_JSON.Coverage, function (index, slaCoverage) {
if (slaCoverage.SlaId == slaId) {
polyCoordinates = []; // making the polygon store empty
var van_marker = putMarkerOnMap(map, &#x27;&#x27;, vanLat, vanLng, &#x27;&#x27;, vanId, vanImagePath, false, false, false); // putting Van on map
VAN_MARKERS.push(van_marker); // storing Van marker globally
// Plotting VAN&#x27;s reachable points
$.each(slaCoverage.ListCoverage, function (index, point) {
// If lattitude is non null and non-empty then plotting starts
if ((point.VanPositionCoverageVanLatitude != &#x27;&#x27;) &amp;&amp; (point.VanPositionCoverageVanLatitude !== null)) {
var reachablePointId = point.VanPositionCoverageVanId + &#x27;_&#x27; + point.VanPositionCoverageId; // creating Id for van reachbale points
// Plot van reachbale point
var rPoint = putMarkerOnMap(map, &#x27;&#x27;, point.VanPositionCoverageVanLatitude, point.VanPositionCoverageVanLongitude, &#x27;&#x27;, reachablePointId, vanReachablePointImagePath, false, false, false)
VAN_REACHABLE_POINT.push(rPoint); // storing van reachable ponit globally
// Storing Point Cordinaates to draw a polygon
var reachablePoint = new google.maps.LatLng(point.VanPositionCoverageVanLatitude, point.VanPositionCoverageVanLongitude);
polyCoordinates.push(reachablePoint);
//latlngbounds.extend(reachablePoint); // extending lat-long object
// craeting Route Object and storing that globally.
var routeObj = new Object({ &#x27;routeId&#x27;: reachablePointId, &#x27;source&#x27;: sourceVan, &#x27;destination&#x27;: reachablePoint });
//ROUTES.push(routeObj);
VAN_ROUTES.push(routeObj);
}
});
// Draw polygon and storing them globally
var polygon = drawPolygon(polyCoordinates, vanId);
POLYGONS.push(polygon);
// Drawing path by sending route request effectively to Direction Service
drawPathManager();
}
});
}
// If there is no exiting coverage for a van and covearge is designed for at least one sla then disable the coverage design now.
if (!isCoverageExist &amp;&amp; VAN_MARKERS.length &gt; 0) {
disable_map_click_Listener = true; // disabling map click
disable_map_mousemove_Listener = true; // dsiable the cursor changing on map
// If coverage for diffrent SLA selection is on then remove exiting coverage and draw a new one for new SLA time.
if (enableDiffCoverage) {
deleteVanMarkers(); // Deleting Van-Markers from the map.
deleteAllRoutes(); // Deleting all the routes from the map
deleteAllPolygons(); // Deleting all the polygons
deleteAllVanReachablePoint(); // Deleting all van reachbale points
MARKERS = []; // making matrker array empty to store frresh ones
VAN_REACHABLE_POINT = []; // making van reachable points array empty to store new ones
var van_marker = putMarkerOnMap(map, &#x27;&#x27;, vanLat, vanLng, &#x27;&#x27;, vanId, vanImagePath, false, false, false); // plotting new van
VAN_MARKERS.push(van_marker); // storing van marker globally
generateVanCoverage(van_marker); // now genearte coverage for van.
}
return;
}
}
/**
* To populate SLA combobox.
* @method loadAllSla
* @for VanCoverageDesigner
*/
function loadAllSla() {
SecurityToken = securityToken;
utcMinutes = parseInt(UtcMinutes, 10);
UserId = userId;
$.ajax({
type: &quot;POST&quot;,
url: WCFRESTURL.GetAllSLA,
data: { Token: SecurityToken, UtcMinutes: utcMinutes, UserId: UserId },
dataType: &quot;json&quot;,
success: function (data) {
allSlaCount = data.length;
var slaList = &#x27;&#x27;;
$.each(data, function (key, item) {
slaList += &#x27;&lt;tr&gt;&lt;td&gt;&lt;input type=&quot;button&quot; id=&quot;&#x27; + item.Id + &#x27;&quot; class=&quot;slaBtn&quot; title=&quot;&#x27; + item.SlaTime + &#x27; Minutes&quot; value=&quot;&#x27; + item.SlaTime + &#x27;&quot; onclick=&quot;return slaButtonClick(this)&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;&#x27;;
//prepare get van coverage json
prepare_GET_VAN_COVERAGE_JSON(item.Id, item.SlaTime);
});
$(&#x27;#slaListBox&#x27;).html(slaList);
//console.log(GET_COVERAGE_JSON);
},
complete: function () {
getExitingVanCoverage(vanId);
},
error: function (jqXHR, textStatus, errorThrown) {
}
});
}
/**
* To draw polygon on map with some lat-long
* @method drawPolygon
* @param {Array} polyCoordinates array of lat-long objects
* @param {String} polygonTitle polygon title
* @for VanCoverageDesigner
*/
function drawPolygon(polyCoordinates, polygonTitle) {
// Construct the polygon.
var polygon = new google.maps.Polygon({
paths: polyCoordinates,
strokeColor: &#x27;#AAA8A5&#x27;,
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: &#x27;#AAA8A5&#x27;,
fillOpacity: 0.35,
title: polygonTitle
});
polygon.setMap(map); // setting the polygon on map
return polygon; // returing the creating polygon
}
/**
* To draw path between two points and setting am routeId for the same. (Blind Spot)
* @method drawPath
* @param {Object} sourcePoint source lat-long
* @param {Object} destinationPoint destination lat-long
* @param {Object} routeId route-id
* @for VanCoverageDesigner
*/
function drawPath(sourcePoint, destinationPoint, routeId) {
if (!directionObj[routeId]) { directionObj[routeId] = []; } // Storing directions
// creting renderer options to draw path on map
var rendererOptions = {
preserveViewport: true,
suppressMarkers: true,
polylineOptions: { strokeColor: &quot;#1b3f94&quot; }
};
directionsRenderer = new google.maps.DirectionsRenderer(rendererOptions); // creating renderer object
directionsRenderer.setMap(map); // setting it on map
directionObj[routeId].push(directionsRenderer); // storing direction globally
// craeting path request between two points
var request = {
origin: sourcePoint,
destination: destinationPoint,
travelMode: google.maps.TravelMode.DRIVING
};
// Route the directions and pass the response to a
// function to create markers for each step.
directionService.route(request, function (response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsRenderer.setDirections(response);
}
});
}
/**
* To manage drawing paths on map at a time interval (Blind Spot)
* @method drawPathManagerForMovedVan
* @for VanCoverageDesigner
*/
function drawPathManager() {
$(&quot;#div_load&quot;).show(); // showing loading
var maxTime = 0; // intializing maximum time
// iterating through global route array.
$.each(VAN_ROUTES, function (index, route) {
setTimeout(function () { drawPath(route.source, route.destination, route.routeId); }, ((index + 1) * 600)); // drawing path at an interval
maxTime = (index + 1) * 600; // inceasing loading time
});
disable_map_click_Listener = true;
disable_map_mousemove_Listener = true;
setTimeout(function () {
$(&quot;#div_load&quot;).hide(); // hiding loading
// Fitting all the markers on map area present on screen
map.fitBounds(latlngbounds);
}, (maxTime + 500));
}
/**
* To get circular points at a distance and at an angle.
* @method getCoverageForVan
* @param {Double} newLatOfVan marker&#x27;s new lattitude
* @param {Double} newLongOfVan marker&#x27;s new longitude
* @param {Int} slaTimeInMin SLA time in minutes
* @param {Int} minRadius minimum radius
* @for VanCoverageDesigner
*/
function getCoverageForVan(newLatOfVan, newLongOfVan, slaTimeInMin) {
var vanLocation = new google.maps.LatLng(newLatOfVan, newLongOfVan);
minRadius = radiusAccToSlaObj[slaTimeInMin];
var radiusArray = [];
radiusArray.push(minRadius);
radiusArray.push(minRadius + radiusIncrement);
radiusArray.push(minRadius + (2 * radiusIncrement));
radiusArray.push(minRadius + (3 * radiusIncrement));
var points = [];
for (var angle = 0; angle &lt; 360; angle += pointAngle) {
for (var i = 0; i &lt; radiusArray.length; i++) {
var point = vanLocation.destinationPoint(angle, radiusArray[i]);
points.push(point);
}
}
return points;
}
/**
* To get circular points at a distance and at an angle.
* @method getCoverageForVanStatic
* @param {Double} newLatOfVan marker&#x27;s new lattitude
* @param {Double} newLongOfVan marker&#x27;s new longitude
* @param {Int} slaTimeInMin SLA time in minutes
* @param {Int} minRadius minimum radius
* @for VanCoverageDesigner
*/
function getCoverageForVanStatic(newLatOfVan, newLongOfVan, slaTimeInMin) {
var vanLocation = new google.maps.LatLng(newLatOfVan, newLongOfVan);
minRadius = radiusAccToSlaObj[slaTimeInMin];
var radiusArray = [];
radiusArray.push(minRadius);
var points = [];
for (var angle = 0; angle &lt; 360; angle += pointAngle) {
for (var i = 0; i &lt; radiusArray.length; i++) {
var point = vanLocation.destinationPoint(angle, radiusArray[i]);
points.push(point);
}
}
return points;
}
/**
* To create Van Coverage JSON for a particular SLA and reachable Points.
* @method create_VAN_COVERAGE_JSON
* @param {Int} slaId SLA ID
* @param {Int} slaTimeInMin SLA Time (In minutes)
* @param {Array} reachablePoints Array contains lat-long objects.
* @for VanCoverageDesigner
*/
function create_VAN_COVERAGE_JSON(slaId, slaTimeInMin, reachablePoints) {
// Taking temporary covearge JSON
var temp_COVERAGE_JSON =
{
&quot;SlaId&quot;: &quot;&quot;,
&quot;SlaValue&quot;: null,
&quot;ListCoverage&quot;: [
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; }
]
};
//================ Design Coverage ======================
temp_COVERAGE_JSON[&#x27;SlaId&#x27;] = slaId; // Binding SLA Id
temp_COVERAGE_JSON[&#x27;SlaValue&#x27;] = slaTimeInMin; // Binding SLA Time
// Binding reachable point&#x27;s lat-long
$.each(reachablePoints, function (index, item) {
temp_COVERAGE_JSON[&#x27;ListCoverage&#x27;][index][&#x27;VanPositionCoverageVanLatitude&#x27;] = item.lat();
temp_COVERAGE_JSON[&#x27;ListCoverage&#x27;][index][&#x27;VanPositionCoverageVanLongitude&#x27;] = item.lng();
});
// If main Coverage JSON is empty, then push the newly craeted JSON object to that, Else replace that with the existing object
if (COVERAGE_JSON.length == 0) {
COVERAGE_JSON.push(temp_COVERAGE_JSON);
} else {
for (var i = 0; i &lt; COVERAGE_JSON.length; i++) {
if (COVERAGE_JSON[i].SlaId == slaId) {
COVERAGE_JSON.splice(i, 1);
COVERAGE_JSON.push(temp_COVERAGE_JSON);
} else {
COVERAGE_JSON.push(temp_COVERAGE_JSON);
}
}
}
//================ Design Coverage ======================
}
/**
* To create Van Coverage JSON for a particular SLA to store exiting Covearge.
* @method prepare_GET_VAN_COVERAGE_JSON
* @param {Int} slaId SLA ID
* @param {Int} slaTimeInMin SLA Time (In minutes)
* @for VanCoverageDesigner
*/
function prepare_GET_VAN_COVERAGE_JSON(slaId, slaTimeInMin) {
// Taking temporary covearge JSON
var temp_COVERAGE_JSON =
{
&quot;SlaId&quot;: &quot;&quot;,
&quot;SlaValue&quot;: null,
&quot;ListCoverage&quot;: [
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; },
{ &quot;VanPositionCoverageId&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLatitude&quot;: &quot;&quot;, &quot;VanPositionCoverageVanLongitude&quot;: &quot;&quot; }
]
};
temp_COVERAGE_JSON[&#x27;SlaId&#x27;] = slaId; // Binding SLA Id
temp_COVERAGE_JSON[&#x27;SlaValue&#x27;] = slaTimeInMin; // Binding SLA Time
GET_COVERAGE_JSON.push(temp_COVERAGE_JSON); // Adding this newly created object to global JSON (which stores existing Coverage objects)
}
/**
* To generate van coverage for a marker
* @method generateVanCoverage
* @param {Object} marker marker object
* @for VanCoverageDesigner
*/
function generateVanCoverageStatic(marker) {
//$(&quot;#div_load&quot;).show(); // showing loading
var vanId = marker.id; // getting van id
//enableCoverageDesign = true; // Enabling Coverage design
var newLatOfVan = marker.position.lat(); // getting new lat of marker
var newLongOfVan = marker.position.lng(); // getting new long of marker
// Getting Van reachable points at a given radius
var final_vanReachablePoints = getCoverageForVanStatic(newLatOfVan, newLongOfVan, slaTimeInMin);
//================== Design Coverage =====================
var sourceVan = new google.maps.LatLng(newLatOfVan, newLongOfVan); // craeting source van lat-long object
var polyCoordinates = []; // takign polygon lat-long array
coverageDesiged = true; // Coverage is designed once for this van
// Plotting VAN&#x27;s reachable points
$.each(final_vanReachablePoints, function (index, point) {
//if ((typeof point === &#x27;undefined&#x27;) || (enableCoverageDesign == false)) {
// if (popTheVanOut &amp;&amp; VAN_MARKERS.length &gt; 0) {
// var currentVanMarker = VAN_MARKERS[VAN_MARKERS.length - 1]; // getting last van marker
// VAN_MARKERS.pop(); // poping out last van from global array
// currentVanMarker.setMap(null); // removing that from map
// popTheVanOut = false; // disabling poping the van out further
// }
// jAlert(EOS_VAN_COVERAGE_DESIGN_MSG[&#x27;no_response_google_error&#x27;], &#x27;Message&#x27;);
// //$(&quot;#div_load&quot;).hide(); // hiding the loading
// return;
//};
latlngbounds.extend(point); // extending lat-long object
var reachablePointId = vanId + &#x27;_&#x27; + index;
var rPoint = putMarkerOnMap(map, &quot;&quot;, point.lat(), point.lng(), &quot;&quot;, reachablePointId, vanReachablePointImagePath, false, false, false);
VAN_REACHABLE_POINT.push(rPoint);
// Storing Point Cordinaates to draw a polygon
var reachablePoint = new google.maps.LatLng(point.lat(), point.lng());
polyCoordinates.push(reachablePoint);
// craeting Route Object and storing that globally.
var routeObj = new Object({ &#x27;routeId&#x27;: reachablePointId, &#x27;source&#x27;: sourceVan, &#x27;destination&#x27;: reachablePoint });
//ROUTES.push(routeObj);
VAN_ROUTES.push(routeObj);
});
// Draw polygon and storing them globally
var polygon = drawPolygon(polyCoordinates, vanId);
POLYGONS.push(polygon);
// Create JSON for all possible SLAs.
create_VAN_COVERAGE_JSON(slaId, slaTimeInMin, final_vanReachablePoints);
// Drawing path Van
drawPathManager();
enableDiffCoverage = true; // enabling diff SLA click to design coverage
return;
//================== Design Coverage =====================
}
/**
* To generate van coverage for a marker
* @method generateVanCoverage
* @param {Object} marker marker object
* @for VanCoverageDesigner
*/
function generateVanCoverage(marker) {
//$(&quot;#div_load&quot;).show(); // showing loading
var vanId = marker.id; // getting van id
enableCoverageDesign = true; // Enabling Coverage design
coverageDesiged = false; // Coverage is not designed yet
popTheVanOut = true; // enabling deleting the last van
VAN_ROUTES = []; // Making the Moved-Van-Routes array empty.
var newLatOfVan = marker.position.lat(); // getting new lat of marker
var newLongOfVan = marker.position.lng(); // getting new long of marker
// Getting Van reachable points at a given radius
var vanReachablePoints = getCoverageForVan(newLatOfVan, newLongOfVan, slaTimeInMin);
var vanReachablePoints1 = [];
var vanReachablePoints2 = [];
var mid = parseInt(vanReachablePoints.length / 2);
for (var i = 0; i &lt; mid ; i++) {
vanReachablePoints1.push(vanReachablePoints[i])
vanReachablePoints2.push(vanReachablePoints[mid + i]);
}
//----------------------
var final_vanReachablePoints = [];
//================== Design Coverage =====================
// Getting optimal reachable points for first 0 to 180 degrees
setTimeout(function () {
var request1 = {
origins: [marker.position],
destinations: vanReachablePoints1,
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC,
avoidHighways: false,
avoidTolls: false
}
distanceMatrixService.getDistanceMatrix(request1, function (response, status) {
if (status == google.maps.DistanceMatrixStatus.OK) {
var result = response.rows[0].elements;
var start = 1;
var counter = 0;
// getting optimal points for 0 to 180 degrees
for (var index = 0; index &lt; result.length; index++) {
if (typeof result[index].duration === &#x27;undefined&#x27;) {
//if (VAN_MARKERS.length &gt; 0) {
// var currentVanMarker = VAN_MARKERS[VAN_MARKERS.length - 1]; // getting last van marker
// VAN_MARKERS.pop(); // poping out last van from global array
// currentVanMarker.setMap(null); // removing that from map
// popTheVanOut = false; // disabling poping the van out further
//}
//jAlert(EOS_VAN_COVERAGE_DESIGN_MSG[&#x27;no_response_google_error&#x27;], &#x27;Message&#x27;);
////MAIN_EXCHANGE_JSON = temp_MAIN_EXCHANGE_JSON;
//COVERAGE_JSON = [];
generateVanCoverageStatic(marker);
enableCoverageDesign = false; // disabling coverage design
//$(&quot;#div_load&quot;).hide(); // hiding loading
return;
};
var durationInMin = parseInt(result[index].duration.value / 60, 10); // getting duration in minutes
counter++;
// getting optimal points for current SLA time
if ((durationInMin &gt; (slaTimeInMin * coverageMultiplier)) || (counter == 4)) {
((index - 1) == -1) ? final_vanReachablePoints.push(vanReachablePoints1[index]) : final_vanReachablePoints.push(vanReachablePoints1[index - 1]);
index = start * 4;
start++;
counter = 0;
}
}
}
});
}, 300);
//--------------------------------
// Getting optimal reachable points for 180 to 360 degrees
setTimeout(function () {
if (coverageDesiged) { return;}
var request2 = {
origins: [marker.position],
destinations: vanReachablePoints2,
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC,
avoidHighways: false,
avoidTolls: false
}
distanceMatrixService.getDistanceMatrix(request2, function (response, status) {
if (status == google.maps.DistanceMatrixStatus.OK) {
var result = response.rows[0].elements;
var start = 1;
var counter = 0;
// getting optimal points
for (var index = 0; index &lt; result.length; index++) {
if ((typeof result[index].duration === &#x27;undefined&#x27;) &amp;&amp; (enableCoverageDesign == true)) {
//if (popTheVanOut &amp;&amp; VAN_MARKERS.length &gt; 0) {
// var currentVanMarker = VAN_MARKERS[VAN_MARKERS.length - 1]; // getting last van marker
// VAN_MARKERS.pop(); // poping out last van from global array
// currentVanMarker.setMap(null); // removing that from map
// popTheVanOut = false; // disabling poping the van out further
//}
//jAlert(EOS_VAN_COVERAGE_DESIGN_MSG[&#x27;no_response_google_error&#x27;], &#x27;Message&#x27;);
////MAIN_EXCHANGE_JSON = temp_MAIN_EXCHANGE_JSON;
//COVERAGE_JSON = [];
generateVanCoverageStatic(marker);
//$(&quot;#div_load&quot;).hide(); // hiding loading
return;
};
var durationInMin = parseInt(result[index].duration.value / 60, 10); // getting duration in minutes
counter++;
// getting optimal points for current SLA time
if ((durationInMin &gt; (slaTimeInMin * coverageMultiplier)) || (counter == 4)) {
((index - 1) == -1) ? final_vanReachablePoints.push(vanReachablePoints2[index]) : final_vanReachablePoints.push(vanReachablePoints2[index - 1]);
index = start * 4;
start++;
counter = 0;
}
}
//--------------------Plotting van, its points and drawing paths and polygon------------------
var sourceVan = new google.maps.LatLng(newLatOfVan, newLongOfVan); // craeting source van lat-long object
var polyCoordinates = []; // takign polygon lat-long array
// Plotting VAN&#x27;s reachable points
$.each(final_vanReachablePoints, function (index, point) {
if ((typeof point === &#x27;undefined&#x27;) || (enableCoverageDesign == false)) {
if (popTheVanOut &amp;&amp; VAN_MARKERS.length &gt; 0) {
var currentVanMarker = VAN_MARKERS[VAN_MARKERS.length - 1]; // getting last van marker
VAN_MARKERS.pop(); // poping out last van from global array
currentVanMarker.setMap(null); // removing that from map
popTheVanOut = false; // disabling poping the van out further
}
jAlert(EOS_VAN_COVERAGE_DESIGN_MSG[&#x27;no_response_google_error&#x27;], &#x27;Message&#x27;);
//$(&quot;#div_load&quot;).hide(); // hiding the loading
return;
};
latlngbounds.extend(point); // extending lat-long object
var reachablePointId = vanId + &#x27;_&#x27; + index;
var rPoint = putMarkerOnMap(map, &quot;&quot;, point.lat(), point.lng(), &quot;&quot;, reachablePointId, vanReachablePointImagePath, false, false, false);
VAN_REACHABLE_POINT.push(rPoint);
// Storing Point Cordinaates to draw a polygon
var reachablePoint = new google.maps.LatLng(point.lat(), point.lng());
polyCoordinates.push(reachablePoint);
// craeting Route Object and storing that globally.
var routeObj = new Object({ &#x27;routeId&#x27;: reachablePointId, &#x27;source&#x27;: sourceVan, &#x27;destination&#x27;: reachablePoint });
//ROUTES.push(routeObj);
VAN_ROUTES.push(routeObj);
});
// Draw polygon and storing them globally
var polygon = drawPolygon(polyCoordinates, vanId);
POLYGONS.push(polygon);
// Create JSON for all possible SLAs.
create_VAN_COVERAGE_JSON(slaId, slaTimeInMin, final_vanReachablePoints);
// Drawing path Van
drawPathManager();
enableDiffCoverage = true; // enabling diff SLA click to design coverage
return;
//------------------------------------------------------------------------------
}
});
}, 1000);
//================== Design Coverage =====================
}
/**
* To put a marker on map with supplied information. (Blind Spot)
* @method putMarkerOnMap
* @param {Object} map map object
* @param {String} markerInfoWindowContent info-window html string
* @param {Object} markerLat marker&#x27;s lat
* @param {Object} markerLong marker&#x27;s long
* @param {Object} markerTitle marker&#x27;s title
* @param {Object} markerId marker&#x27;s id
* @param {Object} markerImage marker&#x27;s icon image
* @param {Object} isDraggable true if marker is draggable
* @param {Object} setMapCenter true if marker click will center the map
* @param {Object} openInfoWindow true if info window should open
* @for VanCoverageDesigner
*/
function putMarkerOnMap(map, markerInfoWindowContent, markerLat, markerLong, markerTitle, markerId, markerImage, isDraggable, setMapCenter, openInfoWindow) {
var markerLatlng = new google.maps.LatLng(markerLat, markerLong); // creating lat-long object
var infowindow = new google.maps.InfoWindow({ content: markerInfoWindowContent }); // creating info-window object
// creating marker object
var marker = new google.maps.Marker({
position: markerLatlng,
map: map,
title: markerTitle,
icon: markerImage,
draggable: isDraggable,
id: markerId
});
return marker;
}
//===============================================================================
//===================== Google Map Initialization ===============================
/**
* To initialize the map and binding the event handlers
* @method initialize
* @for VanCoverageDesigner
*/
function initialize() {
var myLatlng = new google.maps.LatLng(defaultLat, defaultLng);
var mapOptions = {
zoom: 7,
center: myLatlng
};
map = new google.maps.Map(document.getElementById(&#x27;map-canvas&#x27;), mapOptions);
//Initialize the Direction Service
directionService = new google.maps.DirectionsService();
// Creating an instance of Google Distance Matrix
distanceMatrixService = new google.maps.DistanceMatrixService();
//================ Map Events =========================
google.maps.event.addListener(map, &#x27;click&#x27;, function (event) {
if (disable_map_click_Listener) {
return;
}
// if VAN is click on Map
if (!disable_map_click_Listener) {
vanId = $(&#x27;#vanId&#x27;).val();
vanLat = event.latLng.lat();
vanLng = event.latLng.lng();
latlngbounds = new google.maps.LatLngBounds(); // Creating Lat-Long bounds instance to fit all the markers on the map
latlngbounds.extend(event.latLng); // extending lat-long object
var van_marker = putMarkerOnMap(map, &#x27;&#x27;, vanLat, vanLng, &#x27;&#x27;, vanId, vanImagePath, false, false, false);
VAN_MARKERS.push(van_marker);
generateVanCoverage(van_marker);
}
});
google.maps.event.addListener(map, &#x27;mousemove&#x27;, function (event) {
if (disable_map_mousemove_Listener) {
map.setOptions({ draggableCursor: &#x27;&#x27; });
}
if (!disable_map_mousemove_Listener) {
map.setOptions({ draggableCursor: &quot;url(&quot; + vanToolImagePath + &quot;), auto&quot; })
}
});
//============================================================
}
//===============================================================================
//===============================================================================
$(document).ready(function () {
$(&#x27;#coverageBtns&#x27;).hide(); // hides coverage design buttons
vanId = $(&#x27;#vanId&#x27;).val(); // getting VanId from hidden field
$(&quot;#div_load&quot;).hide(); // hiding loading
loadAllSla(); // Loading all SLA buttons
setTimeout(function () { initialize(); }, 500); // Note::: Important: Intializing map after DOM has loaded in the popup
});
</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>
<script src="../assets/js/yui-prettify.js"></script>
<script src="../assets/../api.js"></script>
<script src="../assets/js/api-filter.js"></script>
<script src="../assets/js/api-list.js"></script>
<script src="../assets/js/api-search.js"></script>
<script src="../assets/js/apidocs.js"></script>
</body>
</html>