Last active
August 29, 2015 14:24
-
-
Save devfred/e3bd4aa87cbe6cfa0b7a to your computer and use it in GitHub Desktop.
Titanium app - open map/navigation app in android from WebView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Bind = function(evtName, handler){ | |
Ti.App.addEventListener('app:' + evtName, handler); | |
}; | |
var NavigateTo = function(e){ | |
Ti.Platform.openURL('http://maps.google.com/maps?daddr=' + e.dest +'&directionsmode=driving'); | |
}; | |
Bind('NavigateTo', NavigateTo); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Ti; | |
if(window.parent && window.parent.Ti){ | |
Ti = window.parent.Ti; | |
} | |
var Trigger = function(evtName, data){ | |
if(Ti){ | |
Ti.App.fireEvent('app:' + evtName, data); | |
} | |
}; | |
// USAGE | |
Trigger('NavigateTo', { dest: 'Charlotte, NC 28273' }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment