1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| import Felgo 3.0
import QtQuick 2.0
import QtLocation 5.12
import QtPositioning 5.12
Page {
id:searchProductsPage
title: qsTr("Product Cross")
// show the map
AppMap {
anchors.fill: parent
// set QT_NMEA_SERIAL_PORT=COM3
plugin: Plugin {
name: "mapbox"
// configure your own map_id and access_token here
parameters: [
PluginParameter {
name: "mapbox.mapping.map_id"
value: "mapbox.streets"
}
,
PluginParameter {
name: "mapbox.access_token"
value: "pk.eyJ1IjoiZ3R2cGxheSIsImEiOiJjaWZ0Y2pkM2cwMXZqdWVsenJhcGZ3ZDl5In0.6xMVtyc0CkYNYup76iMVNQ"
},
PluginParameter {
name: "mapbox.mapping.highdpi_tiles"
value: true
}]
}
PositionSource {
id: positionSource
//onPositionChanged: { planet.source = "images/sun.png"; }
nmeaSource: "socket://127.0.0.1:12345"
onSourceErrorChanged: {
if (sourceError == PositionSource.NoError)
return
console.log("Source error: " + sourceError)
activityText.fadeOut = true
stop()
}
onUpdateTimeout: {
activityText.fadeOut = true
}
}
// configure the map to try to display the user's position
showUserPosition: true
zoomLevel: 13
// check for user position initially when the component is created
Component.onCompleted: {
if (positionSource.supportedPositioningMethods ===
PositionSource.NoPositioningMethods) {
positionSource.nmeaSource = "nmealog.txt";
//sourceText.text = "(filesource): " + printableMethod(positionSource.supportedPositioningMethods);
}
positionSource.update();
if(userPositionAvailable){
center = userPosition.coordinate
}
else {
console.debug("Position not available at creation")
}
}
// once we successfully received the location, we zoom to the user position
onUserPositionAvailableChanged: {
if(userPositionAvailable) {
zoomToUserPosition()
}
else {
console.debug("Position not available at changed")
}
}
}
} |
Partager