Native Map Navigation

You can use navigation feature on the phone by calling native map applications. The URI schemes and parameters declared on Apple Developers and Google Map Documentation. You can use Apple Developers reference for iOS only but you can use Google Map Documentation for both iOS and Android. If maps not installed on devices, maps with navigation opens in the browser. The following example shows how to open default map application on the mobile device.

TypeScript code blocks include examples of how to implement, override and components within the theme. You can create page with the UI Editor to make your page compatible with theming and then you can implement themable components programmatically. Once the page is created with the UI Editor, it generates a class under scripts/generated/pages. You can then extend that class with the following TypeScript classes.

TypeScript
JavaScript
TypeScript
import PageSampleDesign from 'generated/pages/pageSample';
import FlexLayout = require('sf-core/ui/flexlayout');
import Application = require('sf-core/application');
import System = require('sf-core/device/system');
import Button = require('sf-core/ui/button');
//You should create new Page from UI-Editor and extend with it.
export default class Sample extends PageSampleDesign {
btnMapsNavigation: Button;
btnMapsNavigationAHL: Button;
constructor() {
super();
// Overrides super.onShow method
this.onShow = onShow.bind(this, this.onShow.bind(this));
// Overrides super.onLoad method
this.onLoad = onLoad.bind(this, this.onLoad.bind(this));
this.layout.flexDirection = FlexLayout.FlexDirection.ROW;
this.layout.justifyContent = FlexLayout.JustifyContent.CENTER;
this.layout.alignItems = FlexLayout.AlignItems.CENTER;
this.layout.flexWrap = FlexLayout.FlexWrap.WRAP;
}
}
/**
* @event onShow
* This event is called when a page appears on the screen (everytime).
* @param {function} superOnShow super onShow function
* @param {Object} parameters passed from Router.go function
*/
function onShow(superOnShow: () => void) {
const { headerBar } = System.OS === "Android" ? this : this.parentController;
superOnShow();
Application.statusBar.visible = true;
headerBar.visible = true;
}
/**
* @event onLoad
* This event is called once when page is created.
* @param {function} superOnLoad super onLoad function
*/
function onLoad(superOnLoad: () => void) {
superOnLoad();
this.btnMapsNavigation = new Button({
text: "Maps Navigation Smartface",
onPress: function () {
if (System.OS === "Android") {
Application.call({
uriScheme: "https://www.google.com/maps/dir/",
data: {
"api": "1",
"travelmode": "walking",
"dir_action": "navigate",
"destination": "37.4492751,-122.1620912",
}
});
}
else {
Application.call({
uriScheme: "http://maps.apple.com/",
data: {
"daddr": "37.4492751,-122.1620912",
"dirflg": "w"
}
});
}
}
});
this.btnMapsNavigationAHL = new Button({
text: "Maps Navigation Ataturk Airport",
onPress: function () {
if (System.OS === "Android") {
Application.call({
uriScheme: "https://www.google.com/maps/dir/",
data: {
"api": "1",
"travelmode": "walking",
"dir_action": "navigate",
"destination": "40.9829888,28.8104425"
}
});
}
else {
Application.call({
uriScheme: "http://maps.apple.com/",
data: {
"daddr": "40.9829888,28.8104425",
"dirflg": "w"
}
});
}
}
});
this.layout.addChild(this.btnMapsNavigation, "btnMapsNavigation", ".sf-button", {
height: 75,
width: 100,
margin: 10,
backgroundColor: "#0000FF",
textColor: "#FFFFFF"
});
this.layout.addChild(this.btnMapsNavigationAHL, "btnMapsNavigationAHL", ".sf-button", {
height: 75,
width: 100,
margin: 10,
backgroundColor: "#0000FF",
textColor: "#FFFFFF"
});
}
JavaScript
e/ui/flexlayout");
const Application = require("sf-core/application");
const System = require("sf-core/device/system");
var page1 = extend(Page)(
function(_super) {
_super(this);
var btnMapsNavigation = new Button({
height: 75,
width: 100,
margin: 10,
text: "Maps Navigation Smartface",
backgroundColor: Color.BLUE,
textColor: Color.WHITE,
onPress: function(){
if(System.OS === "Android"){
Application.call("https://www.google.com/maps/dir/",{
"api": "1",
"travelmode": "walking",
"dir_action": "navigate",
"destination": "37.4492751,-122.1620912",
});
}
else{
Application.call("http://maps.apple.com/",{
"daddr": "37.4492751,-122.1620912",
"dirflg": "w"
});
}
}
});
var btnMapsNavigationAHL = new Button({
height: 75,
width: 100,
margin: 10,
text: "Maps Navigation Ataturk Airport",
backgroundColor: Color.BLUE,
textColor: Color.WHITE,
onPress: function(){
if(System.OS === "Android"){
Application.call("https://www.google.com/maps/dir/",{
"api": "1",
"travelmode": "walking",
"dir_action": "navigate",
"destination": "40.9829888,28.8104425",
});
}
else{
Application.call("http://maps.apple.com/",{
"daddr": "40.9829888,28.8104425",
"dirflg": "w"
});
}
}
});
this.layout.flexWrap = FlexLayout.FlexWrap.WRAP;
this.layout.flexDirection = FlexLayout.FlexDirection.ROW;
this.layout.addChild(btnMapsNavigation);
this.layout.addChild(btnMapsNavigationAHL);
}
);
module.exports = page1;

List Available Navigation Apps on Android

TypeScript
TypeScript
Application.call({
uriScheme: `geo:37.4492751,37.4492751?q=37.4492751,37.4492751`,
chooserTitle: "",
isShowChooser: true
});