import { common, Want } from '@kit.AbilityKit';
@Entry
@Component
struct Index {
aboutToAppear(): void {
}
StartNavi = ()=>{
let petalMapWant: Want = {
bundleName: 'com.huawei.hmos.maps.app',
uri: 'maps://routes', // 路径规划
// uri: 'maps://navigation', // 导航
parameters: {
// 接入方业务名或包名,Link请求来源。
linkSource: 'com.example.navitest',
destinationLatitude: 40.0382556,
destinationLongitude: 116.3144536,
// 终点Poi ID,如果有,优先使用(Map Kit返回的Poi信息含Poi ID)。
destinationPoiId: '906277887815706098',
destinationName: '北京清河高铁站',
vehicleType: 0 // 交通出行工具。0-驾车, 1-步行, 2-骑行。默认驾车
}
}
let context = getContext(this) as common.UIAbilityContext;
context.startAbility(petalMapWant);
}
build() {
RelativeContainer() {
Text("唤起导航")
.id('HelloWorld')
.fontSize(50)
.fontWeight(FontWeight.Bold)
.alignRules({
center: { anchor: '__container__', align: VerticalAlign.Center },
middle: { anchor: '__container__', align: HorizontalAlign.Center }
})
.onClick(this.StartNavi)
}
.height('100%')
.width('100%')
}
}
评论