main.qml Example File
routemapinvoker/assets/main.qml
import bb.cascades 1.0
import bb.platform 1.0
import bb.data 1.0
Page {
Container {
onCreationCompleted: cinemasDataSource.load()
layout: DockLayout {}
ImageView {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
imageSource: "asset:///images/background.png"
}
Container {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
leftPadding: 30
topPadding: 30
rightPadding: 30
bottomPadding: 30
Label {
horizontalAlignment: HorizontalAlignment.Center
text: qsTr ("Route from main station to...")
textStyle {
base: SystemDefaults.TextStyles.TitleText
textAlign: TextAlign.Center
}
}
ListView {
topMargin: 50
dataModel: cinemasModel
listItemComponents: ListItemComponent {
type: "item"
StandardListItem {
title: ListItemData.Title
description: qsTr ("%1, %2").arg(ListItemData.Address).arg(ListItemData.City)
}
}
onTriggered: {
clearSelection()
select(indexPath)
routeInvoker.endLatitude = dataModel.data(indexPath).Latitude
routeInvoker.endLongitude = dataModel.data(indexPath).Longitude
}
}
Button {
horizontalAlignment: HorizontalAlignment.Center
topMargin: 50
text: qsTr ("Get route")
onClicked: routeInvoker.go();
}
}
}
attachedObjects:[
RouteMapInvoker {
id: routeInvoker
centerLatitude: startLatitude
centerLongitude: startLongitude
},
DataSource {
id: cinemasDataSource
source: "cinemas.xml"
query: "/ResultSet/Result"
onDataLoaded: {
cinemasModel.clear()
cinemasModel.insertList(data)
}
},
GroupDataModel {
id: cinemasModel
grouping: ItemGrouping.None
}
]
}