var DriverHandler = function(TripSvc, MapSvc){ this.handleDrivers = function(drivers, selectedDriverType){ var instance = this; angular.forEach(drivers, function(driver){ // console.log("Handling driver: " + driver.device_id); // console.log(JSON.stringify(driver, null, 4)); instance.handleDriver(driver, selectedDriverType); }); }; this.handleDriver = function(driver, selectedDriverType){ //TODO: there are rules somewhere (user sign in config object?) for removing drivers from the map based on some // conditions (not updating location etc) // EXAMPLE FROM GETACTIVETAXIS // { // "distance": 190.93199635167, // "last_update": 0, // "taxi_value": 190.93199635167, // "device_id": "1ed045afdaa584c3fd2a0ed53af74b5a56676a30", // "time_in": { // // }, // "lng": 151.2076492, // "lat": -33.8637657, // "driveTime": { // "tileId": 5294, // "locationId": 663 // }, // "driverType": "TAXI", // "tagged": false // } // EXAMPLE FROM GETFLAGGEDTAXI // { // "device_id": "71bef55e9d5fd24f8da9105cd090bc260061c34c", // "lat": -33.8642757, // "lng": 151.206831, // "last_update": 81514, // "warning_sent": false, // "driverType": "TAXI" // NOTE: this is actually added by us in the success handler of TripSvc.getFlaggedTaxi call // } // driver.iconImage = "/img/afrodot.svg"; if(driver.driverType){ if(TripSvc.branch.taxi_types_range_lookup.hasOwnProperty(driver.driverType)){ driver.iconImage = TripSvc.branch.taxi_types_range_lookup[driver.driverType].icon_image; } else{ console.log(String.format("No marker icon for driver type: {0}, using default", driver.driverType)); } } if(TripSvc.showTaxisOnMapFromPolling){ var driverType = null; if(driver.driverType){ driverType = driver.driverType.toUpperCase(); } else{ console.log("Driver doesn't have a type, using default"); } var driverTypeIsSelected = driverType == selectedDriverType.toUpperCase(); MapSvc.addOrUpdateDriverMarker(driver, driverTypeIsSelected); } }; };