Commit a0fcfc32 authored by Bon Lemuel Dela Cruz's avatar Bon Lemuel Dela Cruz

Working Version Dec 2016

parent 66930d2e
// Type definitions for Cordova Keyboard plugin
// Project: https://github.com/driftyco/ionic-plugins-keyboard
// Definitions by: Hendrik Maus <https://github.com/hendrikmaus>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module Ionic {
interface Keyboard {
/**
* Hide the keyboard accessory bar with the next, previous and done buttons.
*
* @param hide
*/
hideKeyboardAccessoryBar(hide:boolean): void;
/**
* Close the keyboard if it is open.
*/
close(): void;
/**
* Force keyboard to be shown on Android.
* This typically helps if autofocus on a text element does not pop up the keyboard automatically
*
* Supported Platforms: Android, Blackberry 10
*/
show(): void;
/**
* Disable native scrolling, useful if you are using JavaScript to scroll
*
* @param disbale
*/
disableScroll(disbale:boolean): void;
/**
* Whether or not the keyboard is currently visible.
*/
isVisible: boolean;
}
}
// Type definitions for Apache Cordova
// Project: http://cordova.apache.org
// Definitions by: Microsoft Open Technologies Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Cordova {
/** Invokes native functionality by specifying corresponding service name, action and optional parameters.
* @param success A success callback function.
* @param fail An error callback function.
* @param service The service name to call on the native side (corresponds to a native class).
* @param action The action name to call on the native side (generally corresponds to the native class method).
* @param args An array of arguments to pass into the native environment.
*/
exec(success: () => any, fail: () => any, service: string, action: string, args?: string[]): void;
/** Gets the operating system name. */
platformId: string;
/** Gets Cordova framework version */
version: string;
/** Defines custom logic as a Cordova module. Other modules can later access it using module name provided. */
define(moduleName: string, factory: (require: any, exports: any, module: any) => any): void;
/** Access a Cordova module by name. */
require(moduleName: string): any;
/** Namespace for Cordova plugin functionality */
plugins:CordovaPlugins;
}
interface CordovaPlugins {}
interface Document {
addEventListener(type: "deviceready", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "resume", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "backbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "menubutton", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "searchbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "startcallbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "endcallbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "volumedownbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "volumeupbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
removeEventListener(type: "deviceready", listener: (ev: Event) => any, useCapture?: boolean): void;
removeEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void;
removeEventListener(type: "resume", listener: (ev: Event) => any, useCapture?: boolean): void;
removeEventListener(type: "backbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
removeEventListener(type: "menubutton", listener: (ev: Event) => any, useCapture?: boolean): void;
removeEventListener(type: "searchbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
removeEventListener(type: "startcallbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
removeEventListener(type: "endcallbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
removeEventListener(type: "volumedownbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
removeEventListener(type: "volumeupbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void;
}
interface Window {
cordova:Cordova;
}
// cordova/argscheck module
interface ArgsCheck {
checkArgs(argsSpec: string, functionName: string, args: any[], callee?: any): void;
getValue(value?: any, defaultValue?: any): any;
enableChecks: boolean;
}
// cordova/urlutil module
interface UrlUtil {
makeAbsolute(url: string): string
}
/** Apache Cordova instance */
declare var cordova: Cordova;
declare module 'cordova' {
export = cordova;
}
// Type definitions for Apache Cordova Device plugin.
// Project: https://github.com/apache/cordova-plugin-device
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
/**
* This plugin defines a global device object, which describes the device's hardware and software.
* Although the object is in the global scope, it is not available until after the deviceready event.
*/
interface Device {
/** Get the version of Cordova running on the device. */
cordova: string;
/**
* The device.model returns the name of the device's model or product. The value is set
* by the device manufacturer and may be different across versions of the same product.
*/
model: string;
/** Get the device's operating system name. */
platform: string;
/** Get the device's Universally Unique Identifier (UUID). */
uuid: string;
/** Get the operating system version. */
version: string;
/** Get the device's manufacturer. */
manufacturer: string;
/** Whether the device is running on a simulator. */
isVirtual: boolean;
/** Get the device hardware serial number. */
serial: string;}
declare var device: Device;
\ No newline at end of file
// Type definitions for Apache Cordova Dialogs plugin.
// Project: https://github.com/apache/cordova-plugin-dialogs
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Navigator {
/** This plugin provides access to some native dialog UI elements. */
notification: Notification
}
/** This plugin provides access to some native dialog UI elements. */
interface Notification {
/**
* Shows a custom alert or dialog box. Most Cordova implementations use a native dialog box for this feature,
* but some platforms use the browser's alert function, which is typically less customizable.
* @param message Dialog message.
* @param alertCallback Callback to invoke when alert dialog is dismissed.
* @param title Dialog title, defaults to 'Alert'.
* @param buttonName Button name, defaults to OK.
*/
alert(message: string,
alertCallback: () => void,
title?: string,
buttonName?: string): void;
/**
* The device plays a beep sound.
* @param times The number of times to repeat the beep.
*/
beep(times: number): void;
/**
* Displays a customizable confirmation dialog box.
* @param message Dialog message.
* @param confirmCallback Callback to invoke with index of button pressed (1, 2, or 3)
* or when the dialog is dismissed without a button press (0).
* @param title Dialog title, defaults to Confirm.
* @param buttonLabels Array of strings specifying button labels, defaults to [OK,Cancel].
*/
confirm(message: string,
confirmCallback: (choice: number) => void,
title?: string,
buttonLabels?: string[]): void;
/**
* Displays a native dialog box that is more customizable than the browser's prompt function.
* @param message Dialog message.
* @param promptCallback Callback to invoke when a button is pressed.
* @param title Dialog title, defaults to "Prompt".
* @param buttonLabels Array of strings specifying button labels, defaults to ["OK","Cancel"].
* @param defaultText Default textbox input value, default: "".
*/
prompt(message: string,
promptCallback: (result: NotificationPromptResult) => void,
title?: string,
buttonLabels?: string[],
defaultText?: string): void;
}
/** Object, passed to promptCallback */
interface NotificationPromptResult {
/**
* The index of the pressed button. Note that the index uses one-based indexing, so the value is 1, 2, 3, etc.
* 0 is the result when the dialog is dismissed without a button press.
*/
buttonIndex: number;
/** The text entered in the prompt dialog box. */
input1: string;
}
\ No newline at end of file
// Type definitions for Apache Cordova InAppBrowser plugin 1.4.0
// Project: https://github.com/apache/cordova-plugin-inappbrowser
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Window {
/**
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
* @param url The URL to load.
* @param target The target in which to load the URL, an optional parameter that defaults to _self.
* @param options Options for the InAppBrowser. Optional, defaulting to: location=yes.
* The options string must not contain any blank space, and each feature's
* name/value pairs must be separated by a comma. Feature names are case insensitive.
*/
open(url: string, target?: "_self", options?: string): InAppBrowser;
/**
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
* @param url The URL to load.
* @param target The target in which to load the URL, an optional parameter that defaults to _self.
* @param options Options for the InAppBrowser. Optional, defaulting to: location=yes.
* The options string must not contain any blank space, and each feature's
* name/value pairs must be separated by a comma. Feature names are case insensitive.
*/
open(url: string, target?: "_blank", options?: string): InAppBrowser;
/**
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
* @param url The URL to load.
* @param target The target in which to load the URL, an optional parameter that defaults to _self.
* @param options Options for the InAppBrowser. Optional, defaulting to: location=yes.
* The options string must not contain any blank space, and each feature's
* name/value pairs must be separated by a comma. Feature names are case insensitive.
*/
open(url: string, target?: "_system", options?: string): InAppBrowser;
/**
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
* @param url The URL to load.
* @param target The target in which to load the URL, an optional parameter that defaults to _self.
* @param options Options for the InAppBrowser. Optional, defaulting to: location=yes.
* The options string must not contain any blank space, and each feature's
* name/value pairs must be separated by a comma. Feature names are case insensitive.
*/
open(url: string, target?: string, options?: string, replace?: boolean): InAppBrowser;
}
/**
* The object returned from a call to window.open.
* NOTE: The InAppBrowser window behaves like a standard web browser, and can't access Cordova APIs.
*/
interface InAppBrowser extends Window {
onloadstart: (type: InAppBrowserEvent) => void;
onloadstop: (type: InAppBrowserEvent) => void;
onloaderror: (type: InAppBrowserEvent) => void;
onexit: (type: InAppBrowserEvent) => void;
// addEventListener overloads
/**
* Adds a listener for an event from the InAppBrowser.
* @param type the event to listen for
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
addEventListener(type: "loadstart", callback: (event: InAppBrowserEvent) => void): void;
/**
* Adds a listener for an event from the InAppBrowser.
* @param type the event to listen for
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
addEventListener(type: "loadstop", callback: (event: InAppBrowserEvent) => void): void;
/**
* Adds a listener for an event from the InAppBrowser.
* @param type the event to listen for
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
addEventListener(type: "loaderror", callback: (event: InAppBrowserEvent) => void): void;
/**
* Adds a listener for an event from the InAppBrowser.
* @param type the event to listen for
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
addEventListener(type: "exit", callback: (event: InAppBrowserEvent) => void): void;
/**
* Adds a listener for an event from the InAppBrowser.
* @param type the event to listen for
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an Event object as a parameter.
*/
addEventListener(type: string, callback: (event: Event) => void): void;
// removeEventListener overloads
/**
* Removes a listener for an event from the InAppBrowser.
* @param type The event to stop listening for.
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
removeEventListener(type: "loadstart", callback: (event: InAppBrowserEvent) => void): void;
/**
* Removes a listener for an event from the InAppBrowser.
* @param type The event to stop listening for.
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
removeEventListener(type: "loadstop", callback: (event: InAppBrowserEvent) => void): void;
/**
* Removes a listener for an event from the InAppBrowser.
* @param type The event to stop listening for.
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
removeEventListener(type: "loaderror", callback: (event: InAppBrowserEvent) => void): void;
/**
* Removes a listener for an event from the InAppBrowser.
* @param type The event to stop listening for.
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
removeEventListener(type: "exit", callback: (event: InAppBrowserEvent) => void): void;
/**
* Removes a listener for an event from the InAppBrowser.
* @param type The event to stop listening for.
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an Event object as a parameter.
*/
removeEventListener(type: string, callback: (event: Event) => void): void;
/** Closes the InAppBrowser window. */
close(): void;
/**
* Displays an InAppBrowser window that was opened hidden. Calling this has no effect
* if the InAppBrowser was already visible.
*/
show(): void;
/**
* Injects JavaScript code into the InAppBrowser window.
* @param script Details of the script to run, specifying either a file or code key.
* @param callback The function that executes after the JavaScript code is injected.
* If the injected script is of type code, the callback executes with
* a single parameter, which is the return value of the script, wrapped in an Array.
* For multi-line scripts, this is the return value of the last statement,
* or the last expression evaluated.
*/
executeScript(script: { code: string }, callback: (result: any) => void): void;
/**
* Injects JavaScript code into the InAppBrowser window.
* @param script Details of the script to run, specifying either a file or code key.
* @param callback The function that executes after the JavaScript code is injected.
* If the injected script is of type code, the callback executes with
* a single parameter, which is the return value of the script, wrapped in an Array.
* For multi-line scripts, this is the return value of the last statement,
* or the last expression evaluated.
*/
executeScript(script: { file: string }, callback: (result: any) => void): void;
/**
* Injects CSS into the InAppBrowser window.
* @param css Details of the script to run, specifying either a file or code key.
* @param callback The function that executes after the CSS is injected.
*/
insertCSS(css: { code: string }, callback: () => void): void;
/**
* Injects CSS into the InAppBrowser window.
* @param css Details of the script to run, specifying either a file or code key.
* @param callback The function that executes after the CSS is injected.
*/
insertCSS(css: { file: string }, callback: () => void): void;
}
interface InAppBrowserEvent extends Event {
/** the eventname, either loadstart, loadstop, loaderror, or exit. */
type: string;
/** the URL that was loaded. */
url: string;
/** the error code, only in the case of loaderror. */
code: number;
/** the error message, only in the case of loaderror. */
message: string;
}
interface Cordova {
InAppBrowser: InAppBrowser;
}
// Type definitions for Apache Cordova Network Information plugin.
// Project: https://github.com/apache/cordova-plugin-network-information
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Navigator {
/**
* This plugin provides an implementation of an old version of the Network Information API.
* It provides information about the device's cellular and wifi connection, and whether the device has an internet connection.
*/
connection: Connection;
// see https://github.com/apache/cordova-plugin-network-information/blob/dev/doc/index.md#api-change
// for
network: {
/**
* This plugin provides an implementation of an old version of the Network Information API.
* It provides information about the device's cellular and wifi connection, and whether the device has an internet connection.
*/
connection: Connection
}
}
interface Document {
addEventListener(type: "online", connectionStateCallback: () => any, useCapture?: boolean): void;
addEventListener(type: "offline", connectionStateCallback: () => any, useCapture?: boolean): void;
}
/**
* The connection object, exposed via navigator.connection, provides information
* about the device's cellular and wifi connection.
*/
interface Connection {
/**
* This property offers a fast way to determine the device's network connection state, and type of connection.
* One of:
* Connection.UNKNOWN
* Connection.ETHERNET
* Connection.WIFI
* Connection.CELL_2G
* Connection.CELL_3G
* Connection.CELL_4G
* Connection.CELL
* Connection.NONE
*/
type: string
}
declare var Connection: {
UNKNOWN: string;
ETHERNET: string;
WIFI: string;
CELL_2G: string;
CELL_3G: string;
CELL_4G: string;
CELL: string;
NONE: string;
}
// Type definitions for Apache Cordova Splashscreen plugin.
// Project: https://github.com/apache/cordova-plugin-splashscreen
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Navigator {
/** This plugin displays and hides a splash screen during application launch. */
splashscreen: {
/** Dismiss the splash screen. */
hide(): void;
/** Displays the splash screen. */
show(): void;
}
}
\ No newline at end of file
// Type definitions for Apache Cordova StatusBar plugin.
// Project: https://github.com/apache/cordova-plugin-statusbar
// Definitions by: Xinkai Chen <https://github.com/Xinkai>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/**
* Global object StatusBar.
*/
interface Window {
StatusBar: StatusBar;
}
/**
* The StatusBar object provides some functions to customize the iOS and Android StatusBar.
*/
interface StatusBar {
/**
* On iOS 7, make the statusbar overlay or not overlay the WebView.
* @param isOverlay On iOS 7, set to false to make the statusbar appear like iOS 6.
* Set the style and background color to suit using the other functions.
*/
overlaysWebView: (isOverlay: boolean) => void;
/**
* Use the default statusbar (dark text, for light backgrounds).
*/
styleDefault: () => void;
/**
* Use the lightContent statusbar (light text, for dark backgrounds).
*/
styleLightContent: () => void;
/**
* Use the blackTranslucent statusbar (light text, for dark backgrounds).
*/
styleBlackTranslucent: () => void;
/**
* Use the blackOpaque statusbar (light text, for dark backgrounds).
*/
styleBlackOpaque: () => void;
/**
* On iOS 7, when you set StatusBar.statusBarOverlaysWebView to false,
* you can set the background color of the statusbar by color name.
* @param color Supported color names are:
* black, darkGray, lightGray, white, gray, red, green, blue, cyan, yellow, magenta, orange, purple, brown
*/
backgroundColorByName: (color: string) => void;
/**
* Sets the background color of the statusbar by a hex string.
* @param color CSS shorthand properties are also supported.
* On iOS 7, when you set StatusBar.statusBarOverlaysWebView to false, you can set the background color of the statusbar by a hex string (#RRGGBB).
* On WP7 and WP8 you can also specify values as #AARRGGBB, where AA is an alpha value
*/
backgroundColorByHexString: (color: string) => void;
/**
* Hide the statusbar.
*/
hide: () => void;
/**
* Show the statusbar.
*/
show: () => void;
/**
* Read this property to see if the statusbar is visible or not.
*/
isVisible: boolean;
}
declare var StatusBar: StatusBar;
This source diff could not be displayed because it is too large. You can view the blob instead.
{}
\ No newline at end of file
...@@ -2,574 +2,562 @@ angular.module('blazer.mapcontrollers', []) ...@@ -2,574 +2,562 @@ angular.module('blazer.mapcontrollers', [])
.controller('MapCtrl', function($scope, $cordovaGeolocation, $cordovaDialogs, $stateParams, $ionicModal, $ionicPopup, $ionicLoading, $interval, $filter, $ionicPopover, getBlazer, postBlazer, $ionicSideMenuDelegate, $ionicHistory, $cordovaNetwork) { .controller('MapCtrl', function($scope, $cordovaGeolocation, $cordovaDialogs, $stateParams, $ionicModal, $ionicPopup, $ionicLoading, $interval, $filter, $ionicPopover, getBlazer, postBlazer, $ionicSideMenuDelegate, $ionicHistory, $cordovaNetwork) {
// CLEAR HISTORY // CLEAR HISTORY
$ionicHistory.clearHistory(); $ionicHistory.clearHistory();
/* SIDE MENU TRIGGER */ /* SIDE MENU TRIGGER */
$ionicSideMenuDelegate.canDragContent(false); // SET SIDE MENU DRAG FALSE $ionicSideMenuDelegate.canDragContent(false); // SET SIDE MENU DRAG FALSE
$scope.openMenu = function(){ $scope.openMenu = function() {
$ionicSideMenuDelegate.toggleLeft(); $ionicSideMenuDelegate.toggleLeft();
} }
/* MAP DEFAULTS */ /* MAP DEFAULTS */
var map = L.map('mapid'); var map = L.map('mapid');
map.setView(new L.LatLng(14.5818, 120.9771), 12); map.setView(new L.LatLng(14.5818, 120.9771), 12);
//MAP BOX //MAP BOX
L.tileLayer(maplayer, { L.tileLayer(maplayer, {
maxZoom: 18, maxZoom: 18,
minZoom: 9, minZoom: 9,
attribution: '© OpenStreetMap contributors' attribution: '© OpenStreetMap contributors'
}).addTo(map); }).addTo(map);
/* MAP COMPONENTS */ /* MAP COMPONENTS */
var markers, circles, line; var markers, circles, line;
$scope.drawMarkers = function(lat, lon, message){ $scope.drawMarkers = function(lat, lon, message) {
markers = new L.marker([lat, lon]).addTo(map); markers = new L.marker([lat, lon]).addTo(map);
markers.bindPopup(message).openPopup(); markers.bindPopup(message).openPopup();
} }
/* Draw Trip Marker */ /* Draw Trip Marker */
$scope.drawTripMarkers = function(lat, lon){ $scope.drawTripMarkers = function(lat, lon) {
markers = new L.marker([lat, lon]).addTo(map); markers = new L.marker([lat, lon]).addTo(map);
markers.bindPopup('On Trip').openPopup(); markers.bindPopup('On Trip').openPopup();
} }
/* Draw Radius */ /* Draw Radius */
$scope.drawCircle = function(lat, lon){ $scope.drawCircle = function(lat, lon) {
circle = L.circle([lat, lon], 500, { circle = L.circle([lat, lon], 500, {
color: '', color: '',
fillColor: '#165c5b', fillColor: '#165c5b',
fillOpacity: 0.3 fillOpacity: 0.3
}).addTo(map); }).addTo(map);
} }
var coordinates = []; // FOR DRAWN LINES var coordinates = []; // FOR DRAWN LINES
var logCoordinates = []; // FOR LOGGING TRIP var logCoordinates = []; // FOR LOGGING TRIP
var setLatLng; var setLatLng;
var coords; var coords;
$scope.drawLineTrack = function(lat, lon){ $scope.drawLineTrack = function(lat, lon) {
var polylineOptions = { var polylineOptions = {
color: '#185c82', color: '#185c82',
weight: 6, weight: 6,
opacity: 0.9 opacity: 0.9
}; };
setLatLng = new L.LatLng(lat, lon); // USING LEAFLET LATLNG setLatLng = new L.LatLng(lat, lon); // USING LEAFLET LATLNG
coords = { lat, lon }; // USING SELF LATLNG coords = { lat, lon }; // USING SELF LATLNG
coordinates.push(coords); coordinates.push(coords);
console.log(coordinates); console.log(coordinates);
line = new L.polyline(coordinates, polylineOptions); line = new L.polyline(coordinates, polylineOptions);
// line.addTo(map); // line.addTo(map);
map.addLayer(line); map.addLayer(line);
// map.fitBounds(line.getBounds()); // zoom the map to the polyline // map.fitBounds(line.getBounds()); // zoom the map to the polyline
// REMOVE MARKERS // REMOVE MARKERS
map.removeLayer(markers); map.removeLayer(markers);
$scope.drawMarkers(lat, lon, 'On Trip'); // DRAW TRIP MARKER ] $scope.drawMarkers(lat, lon, 'On Trip'); // DRAW TRIP MARKER ]
} }
/* EVENT LISTENERS */ /* EVENT LISTENERS */
$scope.mapButton = true; $scope.mapButton = true;
function onMapDrag(e) {
$scope.mapButton = false; function onMapDrag(e) {
console.log("Map Drag ", $scope.mapButton); $scope.mapButton = false;
} console.log("Map Drag ", $scope.mapButton);
function onMapDragEnd(e) { }
$scope.mapButton = true;
console.log("Map Drag ", $scope.mapButton); function onMapDragEnd(e) {
} $scope.mapButton = true;
map.on('move', onMapDrag); // FIRE MAPDRAG console.log("Map Drag ", $scope.mapButton);
map.on('moveend', onMapDragEnd); // FIRE MAPDRAG END }
map.on('move', onMapDrag); // FIRE MAPDRAG
$scope.clearPolylines = function(){ map.on('moveend', onMapDragEnd); // FIRE MAPDRAG END
console.debug("********** Clear Polylines **********");
for(var i = 0; i < coordinates.length; i ++){ $scope.clearPolylines = function() {
map.removeLayer(line._latlngs[i]); console.debug("********** Clear Polylines **********");
console.error("[ CHECK LOOP ]", i +" "+coordinates.length); for (var i = 0; i < coordinates.length; i++) {
console.log("[ DELETE LINES ]", line._latlngs[i]); map.removeLayer(line._latlngs[i]);
// coordinates.splice(i, 1); // REMOVE AN ITEM ON AN ARRAY console.error("[ CHECK LOOP ]", i + " " + coordinates.length);
} console.log("[ DELETE LINES ]", line._latlngs[i]);
} // coordinates.splice(i, 1); // REMOVE AN ITEM ON AN ARRAY
}
/* LOAD USER ON MAP WITH RADIUS */ }
var userLocated = false;
$scope.initializedLocateUser = function(){ /* LOAD USER ON MAP WITH RADIUS */
console.debug("********** Initialized Location **********"); var userLocated = false;
var posOptions = {enableHighAccuracy: true}; $scope.initializedLocateUser = function() {
$cordovaGeolocation.getCurrentPosition(posOptions).then(function (position) { console.debug("********** Initialized Location **********");
map.setView(new L.LatLng(position.coords.latitude, position.coords.longitude), 15); // SET MAP VIEW var posOptions = { enableHighAccuracy: true };
if(userLocated == false){ $cordovaGeolocation.getCurrentPosition(posOptions).then(function(position) {
$scope.drawMarkers(position.coords.latitude, position.coords.longitude, 'Your current location'); // DRAW MARKERS map.setView(new L.LatLng(position.coords.latitude, position.coords.longitude), 15); // SET MAP VIEW
$scope.drawCircle(position.coords.latitude, position.coords.longitude); // DRAW CIRCLE RADIUS if (userLocated == false) {
userLocated = true; $scope.drawMarkers(position.coords.latitude, position.coords.longitude, 'Your current location'); // DRAW MARKERS
} $scope.drawCircle(position.coords.latitude, position.coords.longitude); // DRAW CIRCLE RADIUS
else { userLocated = true;
console.log("USER ALREADY LOCATED"); } else {
userLocated = true; console.log("USER ALREADY LOCATED");
} userLocated = true;
}, function(error) { }
console.log("LOCATING ERROR ", error); }, function(error) {
}); console.log("LOCATING ERROR ", error);
} });
}
/* Calculate Distance between points */
$scope.getDistanceFromLatLonInKm = function(lat1,lon1,lat2,lon2) { /* Calculate Distance between points */
var R = 6371; // Radius of the earth in km $scope.getDistanceFromLatLonInKm = function(lat1, lon1, lat2, lon2) {
var dLat = deg2rad(lat2-lat1); // deg2rad function var R = 6371; // Radius of the earth in km
var dLon = deg2rad(lon2-lon1); var dLat = deg2rad(lat2 - lat1); // deg2rad function
var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.sin(dLon/2) * Math.sin(dLon/2); var dLon = deg2rad(lon2 - lon1);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
var d = R * c; // Distance in km var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
console.log("[ DISTANCE BETWEEN COORDINDATES ]", d); var d = R * c; // Distance in km
return d; console.log("[ DISTANCE BETWEEN COORDINDATES ]", d);
} return d;
}
function deg2rad(deg) {
return deg * (Math.PI/180) function deg2rad(deg) {
} return deg * (Math.PI / 180)
}
/* MAIN ALGORITHM */
var tripStatusRef = false; /* MAIN ALGORITHM */
$scope.getUserLocation = function(){ var tripStatusRef = false;
console.debug("********** Trip Location **********"); $scope.getUserLocation = function() {
var posOptions = {enableHighAccuracy: true}; console.debug("********** Trip Location **********");
$cordovaGeolocation.getCurrentPosition(posOptions).then(function (position) { var posOptions = { enableHighAccuracy: true };
console.log("[ CURRENT LOCATION ]", position.coords); $cordovaGeolocation.getCurrentPosition(posOptions).then(function(position) {
if(!tripStatusRef){ console.log("[ CURRENT LOCATION ]", position.coords);
$scope.drawLineTrack(position.coords.latitude, position.coords.longitude); // INITIAL LINE ON TRIP if (!tripStatusRef) {
tripStatusRef = true; $scope.drawLineTrack(position.coords.latitude, position.coords.longitude); // INITIAL LINE ON TRIP
} tripStatusRef = true;
}
// Filter Coordinates Distance Method
var locationData = { // Filter Coordinates Distance Method
lat: position.coords.latitude, var locationData = {
lng: position.coords.longitude lat: position.coords.latitude,
} lng: position.coords.longitude
}
if(logCoordinates.length > 0) // CHECK IF ARAY IS EMPTY
{ if (logCoordinates.length > 0) // CHECK IF ARAY IS EMPTY
if($scope.getDistanceFromLatLonInKm(locationData.lat, locationData.lng, logCoordinates[0].lat, logCoordinates[0].lng) > 0.03) {
{ if ($scope.getDistanceFromLatLonInKm(locationData.lat, locationData.lng, logCoordinates[0].lat, logCoordinates[0].lng) > 0.03) {
logCoordinates.splice(0, 0, locationData); logCoordinates.splice(0, 0, locationData);
console.log("[ LOCATION ARRAY ]", logCoordinates); console.log("[ LOCATION ARRAY ]", logCoordinates);
$scope.drawLineTrack(position.coords.latitude, position.coords.longitude); // DRAW LINE ON TRIP $scope.drawLineTrack(position.coords.latitude, position.coords.longitude); // DRAW LINE ON TRIP
} } else {
else console.error("[ You need to be 500 meters away from your current position ]", logCoordinates);
{ }
console.error("[ You need to be 500 meters away from your current position ]", logCoordinates); } else {
} logCoordinates.splice(0, 0, locationData);
} console.log("[ INITIAL LOCATION ARRAY ]", logCoordinates);
else }
{
logCoordinates.splice(0, 0, locationData); }, function(error) {
console.log("[ INITIAL LOCATION ARRAY ]", logCoordinates); console.error("GENERAL LOCATION ERROR ", error);
} });
}
}, function(error) {
console.error("GENERAL LOCATION ERROR ", error); $scope.refreshMap = function() {
}); console.debug("********** Refresh Map **********");
} if (userLocated == true) {
map.removeLayer(markers);
$scope.refreshMap = function(){ map.removeLayer(circle);
console.debug("********** Refresh Map **********"); map.removeLayer(geojsonLayer);
if(userLocated == true){ // map.removeLayer(line);
map.removeLayer(markers); console.log("Map refreshed. Layers Removed");
map.removeLayer(circle); userLocated = false;
map.removeLayer(geojsonLayer); }
// map.removeLayer(line); $scope.initializedLocateUser();
console.log("Map refreshed. Layers Removed"); $scope.clearPolylines();
userLocated = false; }
}
$scope.initializedLocateUser(); /* CONFIRM TRIP DESTINATION */
$scope.clearPolylines(); $scope.confirmTripDestination = function() {
} var tripPopup = $ionicPopup.show({
title: 'Trip Destination',
/* CONFIRM TRIP DESTINATION */ subTitle: 'Select your destination',
$scope.confirmTripDestination = function(){ scope: $scope,
var tripPopup = $ionicPopup.show({ buttons: [{
title: 'Trip Destination', text: 'School',
subTitle: 'Select your destination', type: 'button-dark button-outline',
scope: $scope, onTap: function() {
buttons: [ localStorage.setItem("currentTrip", 'trip2');
{ $scope.tripStart();
text: 'School', console.log('Destination to School');
type: 'button-dark button-outline', }
onTap: function() { },
localStorage.setItem("currentTrip", 'trip2'); {
$scope.tripStart(); text: 'Home',
console.log('Destination to School'); type: 'button-dark button-outline',
} onTap: function() {
}, localStorage.setItem("currentTrip", 'trip1');
{ $scope.tripStart();
text: 'Home', console.log('Destination to Home');
type: 'button-dark button-outline', }
onTap: function() { }
localStorage.setItem("currentTrip", 'trip1'); ]
$scope.tripStart(); });
console.log('Destination to Home'); }
}
} /* SET SEARCH BARANGAY */
] $scope.BarangayList = {};
}); $scope.getAllBarangay = function() {
} console.debug("******* GET ALL BARANGAY ******");
getBlazer.getAllBarangay().then(function(data) {
/* SET SEARCH BARANGAY */ $scope.BarangayList = data;
$scope.BarangayList = {}; console.log("[ Barangay Data ]", JSON.stringify($scope.BarangayList));
$scope.getAllBarangay = function(){ });
console.debug("******* GET ALL BARANGAY ******"); }
getBlazer.getAllBarangay().then(function(data){
$scope.BarangayList = data; $scope.selectedBarangayData = '';
console.log("[ Barangay Data ]", JSON.stringify($scope.BarangayList)); $scope.currentBarangay = '';
}); $scope.currentBarangayTime = '';
} $scope.onLoadSelection = function() {
$scope.data = {};
$scope.selectedBarangayData = ''; // An elaborate, custom popup
$scope.currentBarangay = ''; var myPopup = $ionicPopup.show({
$scope.currentBarangayTime = ''; template: '<label class="input-label">Barangay</label><label class="item item-input item-select"><div class="input-label"></div><select ng-model="data.selectedBarangay"><option ng-repeat = "barangay in BarangayList" value="{{barangay.name}}">{{barangay.name}}</option></select></label><label class="input-label">Time</label><label class="item item-input item-select"><div class="input-label"></div><select ng-model="data.selectedBarangayTime"><option value="AM">AM Trips</option><option value="PM">PM Trips</option></select></label>',
$scope.onLoadSelection = function(){ title: 'Select your Barangay',
$scope.data = {}; subTitle: 'To view the most COMMON MODE of transportation in your barangay.',
// An elaborate, custom popup scope: $scope,
var myPopup = $ionicPopup.show({ buttons: [{
template: '<label class="input-label">Barangay</label><label class="item item-input item-select"><div class="input-label"></div><select ng-model="data.selectedBarangay"><option ng-repeat = "barangay in BarangayList" value="{{barangay.name}}">{{barangay.name}}</option></select></label><label class="input-label">Time</label><label class="item item-input item-select"><div class="input-label"></div><select ng-model="data.selectedBarangayTime"><option value="AM">AM Trips</option><option value="PM">PM Trips</option></select></label>', text: 'Select',
title: 'Select your Barangay', type: 'button-dark button-outline',
subTitle: 'To view the most COMMON MODE of transportation in your barangay.', onTap: function(e) {
scope: $scope, console.log("[ SELECT DATA ]", $scope.data.selectedBarangay + " " + $scope.data.selectedBarangayTime);
buttons: [ // LOAD MAP FUNCTIONS
{ $scope.selectedBarangayData = $scope.data.selectedBarangay + " " + $scope.data.selectedBarangayTime;
text: 'Select', $scope.currentBarangay = $scope.data.selectedBarangay;
type: 'button-dark button-outline', $scope.currentBarangayTime = $scope.data.selectedBarangayTime;
onTap: function(e) { $scope.data = {};
console.log("[ SELECT DATA ]", $scope.data.selectedBarangay +" "+ $scope.data.selectedBarangayTime); }
// LOAD MAP FUNCTIONS },
$scope.selectedBarangayData = $scope.data.selectedBarangay +" "+ $scope.data.selectedBarangayTime; {
$scope.currentBarangay = $scope.data.selectedBarangay; text: 'Cancel',
$scope.currentBarangayTime = $scope.data.selectedBarangayTime; type: 'button-dark button-outline',
$scope.data = {}; onTap: function(e) {
} console.log("[ LOAD BARANGAY CANCELLED ]")
}, }
{ }
text: 'Cancel', ]
type: 'button-dark button-outline', });
onTap: function(e) { }
console.log("[ LOAD BARANGAY CANCELLED ]")
} /* CHART JS DATA */
} $scope.BarangayData = {};
] $scope.loadBarangayData = function() {
}); console.debug("********** Get Barangay Data **********");
} var barangayinfo = {
"barangay": $scope.currentBarangay,
/* CHART JS DATA */ "time": $scope.currentBarangayTime
$scope.BarangayData = {}; };
$scope.loadBarangayData = function(){ postBlazer.BarangayInformation(barangayinfo)
console.debug("********** Get Barangay Data **********"); .success(function(response) {
var barangayinfo = { console.log(" BARANGAY SUCCESS", response);
"barangay": $scope.currentBarangay, $scope.BarangayData = response;
"time": $scope.currentBarangayTime console.log('[ BARANGAY DETAILS ]', JSON.stringify($scope.BarangayData));
}; $scope.openChart($scope.BarangayData); // LOAD CHART MODAL
postBlazer.BarangayInformation(barangayinfo) $scope.drawMarkers($scope.BarangayData.lat, $scope.BarangayData.lng, $scope.currentBarangay);
.success(function(response) { // RESET VALUES
console.log(" BARANGAY SUCCESS", response); $scope.selectedBarangayData = '';
$scope.BarangayData = response; $scope.currentBarangay = '';
console.log('[ BARANGAY DETAILS ]', JSON.stringify($scope.BarangayData)); $scope.currentBarangayTime = '';
$scope.openChart($scope.BarangayData); // LOAD CHART MODAL })
$scope.drawMarkers($scope.BarangayData.lat, $scope.BarangayData.lng, $scope.currentBarangay); .error(function(response) {
// RESET VALUES console.error("BARANGAY ERROR", response);
$scope.selectedBarangayData = ''; });
$scope.currentBarangay = ''; }
$scope.currentBarangayTime = '';
}) $scope.labels = ["Car", "Tricycle", "Pedicab", "Jeep", "Bus", "Van", "Walk", "Carpool", "Bicycle", "Train", "Taxi"];
.error(function(response) {
console.error("BARANGAY ERROR", response);
});
}
$scope.labels = ["Car", "Tricycle", "Pedicab", "Jeep", "Bus", "Van", "Walk", "Carpool", "Bicycle", "Train", "Taxi"];
$scope.data = [ $scope.data = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
]; ];
$scope.value = ''; $scope.value = '';
$scope.loadValue = function(val){ $scope.loadValue = function(val) {
$scope.value = val; $scope.value = val;
} }
$ionicModal.fromTemplateUrl('app/map/modal/graph.html', { $ionicModal.fromTemplateUrl('app/map/modal/graph.html', {
scope: $scope, scope: $scope,
animation: 'slide-in-up' animation: 'slide-in-up'
}).then(function(modal) { }).then(function(modal) {
$scope.modalChart = modal; $scope.modalChart = modal;
}); });
/* MODAL LISTENER */ /* MODAL LISTENER */
$scope.$on('modal.hidden', function() { $scope.$on('modal.hidden', function() {
console.log("Modal is Hidden"); console.log("Modal is Hidden");
$scope.labels = ["Car", "Tricycle", "Pedicab", "Jeep", "Bus", "Van", "Walk", "Carpool", "Bicycle", "Train", "Taxi"]; $scope.labels = ["Car", "Tricycle", "Pedicab", "Jeep", "Bus", "Van", "Walk", "Carpool", "Bicycle", "Train", "Taxi"];
$scope.data = [ $scope.data = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
]; ];
}); });
$scope.openChart = function(data) { $scope.openChart = function(data) {
$scope.modalChart.show(); $scope.modalChart.show();
console.log("[ CHART DATA ]", data); console.log("[ CHART DATA ]", data);
$scope.labels = ["Car", "Tricycle", "Pedicab", "Jeep", "Bus", "Van", "Walk", "Carpool", "Bicycle", "Train", "Taxi"]; $scope.labels = ["Car", "Tricycle", "Pedicab", "Jeep", "Bus", "Van", "Walk", "Carpool", "Bicycle", "Train", "Taxi"];
$scope.data = [ $scope.data = [
[data.car, data.tricycle, data.pedicab, data.jeep, data.bus, data.van, data.walk, data.carpool, data.bicycle, data.train, data.taxi] [data.car, data.tricycle, data.pedicab, data.jeep, data.bus, data.van, data.walk, data.carpool, data.bicycle, data.train, data.taxi]
]; ];
}; };
$scope.closeChart = function() { $scope.closeChart = function() {
$scope.modalChart.hide(); $scope.modalChart.hide();
}; };
/* START TRIP */ /* START TRIP */
$scope.tripStatus = false; $scope.tripStatus = false;
var startTime, endTime; var startTime, endTime;
var intervalTrigger; var intervalTrigger;
userLocated = false; userLocated = false;
$scope.tripStart = function(){ $scope.tripStart = function() {
map.removeLayer(markers); map.removeLayer(markers);
map.removeLayer(circle); map.removeLayer(circle);
map.removeLayer(geojsonLayer); map.removeLayer(geojsonLayer);
$scope.tripStatus = true; $scope.tripStatus = true;
var newDate = new Date(); var newDate = new Date();
startTime = newDate.getTime(); startTime = newDate.getTime();
localStorage.setItem("starttime", startTime); localStorage.setItem("starttime", startTime);
console.log("START TRIP TIME", startTime); console.log("START TRIP TIME", startTime);
$scope.getUserLocation(); $scope.getUserLocation();
intervalTrigger = $interval($scope.getUserLocation, 1000); // START FUNCTION CALL 'LOOP'' intervalTrigger = $interval($scope.getUserLocation, 1000); // START FUNCTION CALL 'LOOP''
} }
/* END TRIP */ /* END TRIP */
$scope.tripEnd = function(){ $scope.tripEnd = function() {
/* CHECK IF MOBILE IS ONLINE */ /* CHECK IF MOBILE IS ONLINE */
console.log("[ NETWORK STATUS ]", $cordovaNetwork.getNetwork()); console.log("[ NETWORK STATUS ]", $cordovaNetwork.getNetwork());
if($cordovaNetwork.getNetwork() == Connection.WIFI || $cordovaNetwork.getNetwork() == Connection.CELL_2G || $cordovaNetwork.getNetwork() == Connection.CELL_3G ||$cordovaNetwork.getNetwork() == Connection.CELL_4G){ if ($cordovaNetwork.getNetwork() == Connection.WIFI || $cordovaNetwork.getNetwork() == Connection.CELL_2G || $cordovaNetwork.getNetwork() == Connection.CELL_3G || $cordovaNetwork.getNetwork() == Connection.CELL_4G) {
$scope.tripStatus = false; $scope.tripStatus = false;
tripStatusRef = false; tripStatusRef = false;
var newDate = new Date(); var newDate = new Date();
var endTime = newDate.getTime(); var endTime = newDate.getTime();
localStorage.setItem("endtime", endTime); localStorage.setItem("endtime", endTime);
console.log("END TRIP TIME", endTime); console.log("END TRIP TIME", endTime);
// TRIGGER CLEAR FUNCTION OF REMOVE LINE -- NEEDS TO DEBUG // TRIGGER CLEAR FUNCTION OF REMOVE LINE -- NEEDS TO DEBUG
$scope.clearPolylines(); $scope.clearPolylines();
map.removeLayer(line); // REMOVE LINE TRACK map.removeLayer(line); // REMOVE LINE TRACK
parsedData = []; // CLEAR BLAZER MARKER ARRAY parsedData = []; // CLEAR BLAZER MARKER ARRAY
$interval.cancel(intervalTrigger); // CANCEL FUNCTION CALL $interval.cancel(intervalTrigger); // CANCEL FUNCTION CALL
$scope.sendTrackingLocation(); // SEND LOCATION DATA $scope.sendTrackingLocation(); // SEND LOCATION DATA
$scope.openEndTripSurvey(); // OPEN END TRIP SURVEY $scope.openEndTripSurvey(); // OPEN END TRIP SURVEY
} } else {
else { $cordovaDialogs.alert('You need to be ONLINE before ending this trip. Thank you.', 'Ooops', "OKAY");
$cordovaDialogs.alert('You need to be ONLINE before ending this trip. Thank you.', 'Ooops', "OKAY"); }
} }
}
/* SEND LOCATION DATA */
/* SEND LOCATION DATA */ $scope.sendTrackingLocation = function() {
$scope.sendTrackingLocation = function(){ var username = localStorage.getItem("username");
var username = localStorage.getItem("username"); console.debug("********** Send Tracking Location **********");
console.debug("********** Send Tracking Location **********"); postBlazer.LogTrip(logCoordinates, username)
postBlazer.LogTrip(logCoordinates, username) .success(function(response) {
.success(function(response) { console.log("LOG TRIP SUCCESS", response);
console.log("LOG TRIP SUCCESS", response); coordinates = [];
coordinates = []; logCoordinates = [];
logCoordinates = []; })
}) .error(function(response) {
.error(function(response) { console.error("LOG TRIP ERROR", response);
console.error("LOG TRIP ERROR", response); });
}); }
}
/* LOAD HEATMAP */
/* LOAD HEATMAP */ $scope.loadHeatMap = function() {
$scope.loadHeatMap = function(){ console.debug("********** Load Heat Map **********");
console.debug("********** Load Heat Map **********"); }
}
/* Show Blazers Data */
/* Show Blazers Data */ $scope.blazersData = {};
$scope.blazersData = {}; $scope.getBlazersData = function() {
$scope.getBlazersData = function(){ getBlazer.getBlazerDataInfo().then(function(data) {
getBlazer.getBlazerDataInfo().then(function(data){ $scope.blazersData = data;
$scope.blazersData = data; console.log("[ Blazer Data ]", JSON.stringify($scope.blazersData));
console.log("[ Blazer Data ]", JSON.stringify($scope.blazersData)); $scope.plotBlazers();
$scope.plotBlazers(); });
}); }
}
/* Plot Blazers Data on Map */
/* Plot Blazers Data on Map */ var parsedData = [];
var parsedData = []; var geojsonLayer = [];
var geojsonLayer = []; $scope.plotBlazers = function() {
$scope.plotBlazers = function(){
console.debug("********** Plot Blazers on Map **********");
console.debug("********** Plot Blazers on Map **********");
parsedData = [];
parsedData = []; angular.forEach($scope.blazersData, function(value, key) {
angular.forEach($scope.blazersData, function(value, key) { console.log("[ VALUE SCOPE ]", JSON.stringify(value));
console.log("[ VALUE SCOPE ]", JSON.stringify(value)); var formatData = {
var formatData = { "type": "Feature",
"type": "Feature", "properties": {
"properties": { "username": "Anonymous Blazer",
"username": "Anonymous Blazer", },
}, "geometry": {
"geometry": { "type": "Point",
"type": "Point", "coordinates": [value.longitude, value.latitude]
"coordinates": [value.longitude, value.latitude] }
} }
} parsedData.push(formatData);
parsedData.push(formatData); });
});
// Map Icon Options
// Map Icon Options
// ICON
// ICON // var iconOptions = L.icon({
// var iconOptions = L.icon({ // iconUrl: 'img/mapicon.png',
// iconUrl: 'img/mapicon.png', // iconSize: [35, 37],
// iconSize: [35, 37], // iconAnchor: [18, 2]
// iconAnchor: [18, 2] // });
// });
// POINTS
// POINTS var iconOptions = {
var iconOptions = { radius: 8,
radius: 8, fillColor: "green",
fillColor: "green", color: "green",
color: "green", weight: 1,
weight: 1, opacity: 1,
opacity: 1, fillOpacity: 0.8
fillOpacity: 0.8 };
};
// PLOT DATA
// PLOT DATA function onEachFeature(feature, layer) {
function onEachFeature(feature, layer) if (feature.properties && feature.properties.username) {
{ layer.bindPopup('<div class="pop-up-containter">Blazer</h4><div style="font-size: 15px">' + feature.properties.username + '</div></div>');
if (feature.properties && feature.properties.username) }
{ }
layer.bindPopup('<div class="pop-up-containter">Blazer</h4><div style="font-size: 15px">'+feature.properties.username+'</div></div>'); geojsonLayer = L.geoJson(parsedData, {
} onEachFeature: onEachFeature,
} pointToLayer: function(feature, latlng) {
geojsonLayer = L.geoJson(parsedData, { return L.circleMarker(latlng, iconOptions);
onEachFeature: onEachFeature, }
pointToLayer: function (feature, latlng) { }).addTo(map);
return L.circleMarker(latlng, iconOptions); map.fitBounds(geojsonLayer.getBounds());
} }
}).addTo(map);
map.fitBounds(geojsonLayer.getBounds()); /* Weekly Survey Call */
} $scope.loadWeeklySurvey = function() {
console.debug("********** Open Weekly Survey **********");
/* Weekly Survey Call */ var newDate = new Date();
$scope.loadWeeklySurvey = function(){ var currentDate = $filter('date')(newDate, 'yyyyMMww');
console.debug("********** Open Weekly Survey **********"); var dayToday = $filter('date')(newDate, 'EEEE');
var newDate = new Date(); console.log("[ Date Today ]", currentDate);
var currentDate = $filter('date')(newDate, 'yyyyMMww');
var dayToday = $filter('date')(newDate, 'EEEE'); if (dayToday == 'Friday' || dayToday == 'Saturday') {
console.log("[ Date Today ]" , currentDate); if (localStorage.getItem(currentDate) === null) {
var tripPopup = $ionicPopup.show({
if(dayToday == 'Friday' || dayToday == 'Saturday'){ title: 'Hey it\'s ' + dayToday + '!',
if(localStorage.getItem(currentDate) === null){ subTitle: 'Take the weekly survey. You are awesome!',
var tripPopup = $ionicPopup.show({ scope: $scope,
title: 'Hey it\'s '+dayToday+'!', buttons: [{
subTitle: 'Take the weekly survey. You are awesome!', text: 'Let\s go!',
scope: $scope, type: 'button-dark button-outline',
buttons: [ onTap: function(e) {
{ console.log("[ TAKE WEEKLY SURVEY ]");
text: 'Let\s go!', $scope.openWeeklySurvey();
type: 'button-dark button-outline', }
onTap: function(e) { },
console.log("[ TAKE WEEKLY SURVEY ]"); {
$scope.openWeeklySurvey(); text: 'Later',
} type: 'button-dark button-outline',
}, onTap: function(e) {
{ console.log("[ NO WEEKLY SURVEY ]")
text: 'Later', }
type: 'button-dark button-outline', }
onTap: function(e) { ]
console.log("[ NO WEEKLY SURVEY ]") });
} }
} }
] }
});
} $scope.triggerWeeklySurvey = function() {
} console.debug("********** Trigger Weekly Survey **********");
} var newDate = new Date();
var currentDate = $filter('date')(newDate, 'yyyyMMww');
$scope.triggerWeeklySurvey = function(){ var dayToday = $filter('date')(newDate, 'EEEE');
console.debug("********** Trigger Weekly Survey **********"); console.log("[ Date Today ]", currentDate);
var newDate = new Date();
var currentDate = $filter('date')(newDate, 'yyyyMMww'); if (localStorage.getItem(currentDate) === null) {
var dayToday = $filter('date')(newDate, 'EEEE'); var tripPopup = $ionicPopup.show({
console.log("[ Date Today ]" , currentDate); title: 'Hey it\'s ' + dayToday + '!',
subTitle: 'Take the weekly survey. You are awesome!',
if(localStorage.getItem(currentDate) === null){ scope: $scope,
var tripPopup = $ionicPopup.show({ buttons: [{
title: 'Hey it\'s '+dayToday+'!', text: 'Let\s go!',
subTitle: 'Take the weekly survey. You are awesome!', type: 'button-dark button-outline',
scope: $scope, onTap: function(e) {
buttons: [ console.log("[ TAKE WEEKLY SURVEY ]");
{ $scope.openWeeklySurvey();
text: 'Let\s go!', }
type: 'button-dark button-outline', },
onTap: function(e) { {
console.log("[ TAKE WEEKLY SURVEY ]"); text: 'Later',
$scope.openWeeklySurvey(); type: 'button-dark button-outline',
} onTap: function(e) {
}, console.log("[ NO WEEKLY SURVEY ]")
{ }
text: 'Later', }
type: 'button-dark button-outline', ]
onTap: function(e) { });
console.log("[ NO WEEKLY SURVEY ]") } else {
} $cordovaDialogs.alert('You\'ve already taken this weeks\' weekly survey. Thank you.', 'Weekly Survey', "OKAY");
} }
] }
});
} /* Popover Methods */
else { $ionicPopover.fromTemplateUrl('app/map/popover/map-popover.html', {
$cordovaDialogs.alert('You\'ve already taken this weeks\' weekly survey. Thank you.', 'Weekly Survey', "OKAY"); scope: $scope
} }).then(function(popover) {
} $scope.popover = popover;
});
/* Popover Methods */ $scope.openPopover = function($event) {
$ionicPopover.fromTemplateUrl('app/map/popover/map-popover.html', { $scope.popover.show($event);
scope: $scope console.log("OPEN POPOVER");
}).then(function(popover) { };
$scope.popover = popover; $scope.closePopover = function() {
}); $scope.popover.hide();
$scope.openPopover = function($event) { };
$scope.popover.show($event); $scope.$on('$destroy', function() {
console.log("OPEN POPOVER"); $scope.popover.remove();
}; });
$scope.closePopover = function() { // EndTrip Modal
$scope.popover.hide(); $ionicModal.fromTemplateUrl('app/survey/endtrip.html', {
}; scope: $scope,
$scope.$on('$destroy', function() { animation: 'slide-in-up'
$scope.popover.remove(); }).then(function(modal) {
}); $scope.modalEndTrip = modal;
// EndTrip Modal });
$ionicModal.fromTemplateUrl('app/survey/endtrip.html', { $scope.openEndTripSurvey = function() {
scope: $scope, $scope.modalEndTrip.show();
animation: 'slide-in-up' };
}).then(function(modal) { // Weekly Survey Modal
$scope.modalEndTrip = modal; $ionicModal.fromTemplateUrl('app/survey/weekly.html', {
}); scope: $scope,
$scope.openEndTripSurvey = function() { animation: 'slide-in-up'
$scope.modalEndTrip.show(); }).then(function(modal) {
}; $scope.modalWeeklyTrip = modal;
// Weekly Survey Modal });
$ionicModal.fromTemplateUrl('app/survey/weekly.html', { $scope.openWeeklySurvey = function() {
scope: $scope, $scope.modalWeeklyTrip.show();
animation: 'slide-in-up' };
}).then(function(modal) {
$scope.modalWeeklyTrip = modal;
});
$scope.openWeeklySurvey = function() {
$scope.modalWeeklyTrip.show();
};
}); });
\ No newline at end of file
<ion-side-menus enable-menu-with-back-views="false"> <ion-side-menus enable-menu-with-back-views="false">
<ion-side-menu-content> <ion-side-menu-content>
<ion-nav-bar class="bar bar-clear darkblue"> <ion-nav-bar class="bar bar-clear darkblue">
<ion-nav-back-button> <ion-nav-back-button>
</ion-nav-back-button> </ion-nav-back-button>
<ion-nav-buttons side="left"> <ion-nav-buttons side="left">
<button class="button button-clear button-icon button-clear ion-android-menu" menu-toggle="left"></button> <button class="button button-clear button-icon button-clear ion-android-menu" menu-toggle="left"></button>
</ion-nav-buttons> </ion-nav-buttons>
</ion-nav-bar> </ion-nav-bar>
<ion-nav-view name="menuContent"></ion-nav-view> <ion-nav-view name="menuContent"></ion-nav-view>
</ion-side-menu-content> </ion-side-menu-content>
<ion-side-menu side="left" width="220"> <ion-side-menu side="left" width="220">
<ion-content class="darkSide"> <ion-content class="darkSide">
<h3 class="text-light"><center>BLAZE</center></h3> <h3 class="text-light">
<ion-item nav-clear menu-close href="#/app/profile" class="item-avatar"><ionic-letter-avatar data="{{ user.username }}" shape="round" charcount="2"></ionic-letter-avatar><h4 class="text-light">{{ user.username }}</h4><h5 class="text-light">Blazer User</h5></ion-item> <center>BLAZE</center>
<ion-item nav-clear menu-close href="#/app/map" class="item-icon item-icon-left"><i class="icon ion-android-compass"></i>Blaze Network</ion-item> </h3>
<!-- <ion-item nav-clear menu-close href="#/app/offerride" class="item-icon item-icon-left"><i class="icon ion-android-car"></i>Offer a Ride</ion-item> --> <ion-item nav-clear menu-close href="#/app/profile" class="item-avatar">
<ion-item nav-clear menu-close href="#/app/sharedride" class="item-icon item-icon-left"><i class="icon ion-android-contacts"></i>Shared Ride</ion-item> <ionic-letter-avatar data="{{ user.username }}" shape="round" charcount="2"></ionic-letter-avatar>
<ion-item nav-clear menu-close href="#/app/status" class="item-icon item-icon-left"><i class="icon ion-android-wifi"></i>My Travel Stats</ion-item> <h4 class="text-light">{{ user.username }}</h4>
<ion-item nav-clear menu-close href="#/app/about" class="item-icon item-icon-left"><i class="icon ion-android-bulb"></i>About</ion-item> <h5 class="text-light">Blazer User</h5>
<ion-item nav-clear menu-close href="#/app/settings" class="item-icon item-icon-left"><i class="icon ion-android-settings"></i>Settings</ion-item> </ion-item>
</ion-content> <ion-item nav-clear menu-close href="#/app/map" class="item-icon item-icon-left"><i class="icon ion-android-compass"></i>Blaze Network</ion-item>
</ion-side-menu> <!-- <ion-item nav-clear menu-close href="#/app/offerride" class="item-icon item-icon-left"><i class="icon ion-android-car"></i>Offer a Ride</ion-item> -->
</ion-side-menus> <ion-item nav-clear menu-close href="#/app/sharedride" class="item-icon item-icon-left"><i class="icon ion-android-contacts"></i>Shared Ride</ion-item>
<ion-item nav-clear menu-close href="#/app/status" class="item-icon item-icon-left"><i class="icon ion-android-wifi"></i>My Travel Stats</ion-item>
<ion-item nav-clear menu-close href="#/app/status" class="item-icon item-icon-left"><i class="icon ion-android-wifi"></i>My Diary</ion-item>
<ion-item nav-clear menu-close href="#/app/status" class="item-icon item-icon-left"><i class="icon ion-android-wifi"></i>Trip Logging</ion-item>
<ion-item nav-clear menu-close href="#/app/about" class="item-icon item-icon-left"><i class="icon ion-android-bulb"></i>About</ion-item>
<ion-item nav-clear menu-close href="#/app/settings" class="item-icon item-icon-left"><i class="icon ion-android-settings"></i>Settings</ion-item>
</ion-content>
</ion-side-menu>
</ion-side-menus>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment