diff options
author | Scott Murray <scott.murray@konsulko.com> | 2019-10-20 11:30:15 -0400 |
---|---|---|
committer | Scott Murray <scott.murray@konsulko.com> | 2019-10-20 13:16:26 -0400 |
commit | d7d65ef59bd9e54787fdebebe39ea0d8e1155769 (patch) | |
tree | 26fc3bba8202707beddd2034ebaaecf8c6dd3b09 /app/qml/MapWindow.qml | |
parent | 1d3670c387c43f355f7190274085c55098fac90f (diff) |
Fixes and rework to allow using with cluster demo
Changes include:
- Remove older libhomescreen and qlibwindowmanager detection and
configuration from qmake configuration in favor of PKGCONFIG
usage.
- Rework main.cpp to look more like ondemandnavi, and use
qlibhomescreen instead of libhomescreen.
- Update file_operation.{h,cpp} with the newer versions from
ondemandnavi that include OSM configuration.
- Fixed typo in arrived signal name in org.agl.naviapi.xml and
dbus_client.cpp.
- Change some qDebug messages in dbus_client.cpp to qWarning as it
seems more appropriate.
- Rework QtLocation plugin configuration in MapWindow.qml to
support OSM and replace mapboxgl with mapbox, as mapboxgl does not
seem to work out of the box.
- Tweak various things in MapWindow.qml to try to better match the
look of ondemandnavi.
- Many commenting and whitespace fixes in MapWindow.qml.
- Update widget config.xml to add now required display permission,
and add the hidden permission so the application will not show up
in the launcher.
- Add license files for the various header files in include/mapbox,
and update README.md to indicate where they come from and what
files the different licenses apply to.
Bug-AGL: SPEC-2913
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Change-Id: I192efd45ab94ace8234dbe6c8983257a24e51d23
Diffstat (limited to 'app/qml/MapWindow.qml')
-rw-r--r-- | app/qml/MapWindow.qml | 143 |
1 files changed, 77 insertions, 66 deletions
diff --git a/app/qml/MapWindow.qml b/app/qml/MapWindow.qml index 8a41390..4da46b3 100644 --- a/app/qml/MapWindow.qml +++ b/app/qml/MapWindow.qml @@ -1,6 +1,6 @@ -import QtLocation 5.9 -import QtPositioning 5.0 -import QtQuick 2.0 +import QtQuick 2.0 +import QtLocation 5.9 +import QtPositioning 5.9 import com.mapbox.cheap_ruler 1.0 @@ -12,7 +12,7 @@ Item { property var startPoint property var endPoint - //turn by turn board view + // Turn by turn board view TbtBoard { id: tbt_board z: 1 @@ -20,37 +20,42 @@ Item { anchors.fill: parent } - //mapview and route views - Map { - id: map - anchors.fill: parent - - plugin: Plugin { - name: "mapboxgl" - - PluginParameter { - name: "mapboxgl.mapping.items.insert_before" - value: "road-label-small" - } + Plugin { + id: mapbox + name: "mapbox" + PluginParameter { + name: "mapbox.mapping.items.insert_before" + value: "road-label-small" + } - PluginParameter { - name: "mapboxgl.mapping.additional_style_urls" - value: "mapbox://styles/mapbox/streets-v9" - } + PluginParameter { + name: "mapbox.mapping.additional_style_urls" + value: fileOperation.getMapStyleUrls() + } - PluginParameter { - name: "mapboxgl.access_token" - value: fileOperation.getMapAccessToken() - } + PluginParameter { + name: "mapbox.access_token" + value: fileOperation.getMapAccessToken() + } + } - PluginParameter { - name: "mapboxgl.mapping.cache.directory" - value: "/home/0/app-data/navigation/" - } + Plugin { + id: osm + name: "osm" + PluginParameter { + name: "osm.mapping.host"; + value: "https://a.tile.openstreetmap.org/" } + } + // Map and route views + Map { + id: map + anchors.fill: parent + + plugin: fileOperation.isOSMEnabled() ? osm : mapbox center: ruler.currentPosition - zoomLevel: 20 + zoomLevel: maximumZoomLevel < 20 ? maximumZoomLevel : 20 tilt: 60 gesture.acceptedGestures:MapGestureArea.NoGesture copyrightsVisible: false @@ -88,6 +93,7 @@ Item { } anchorPoint.x: greenMarker.width / 2 anchorPoint.y: greenMarker.height / 2 + z: 11 } MapQuickItem { @@ -99,6 +105,7 @@ Item { } anchorPoint.x: redMarker.width / 2 anchorPoint.y: redMarker.height / 2 + z: 11 } MapItemView { @@ -106,9 +113,11 @@ Item { delegate: MapRoute { route: routeData - line.color: "#6b43a1" + line.color: "#4658da" line.width: map.zoomLevel - 5 - opacity: (index == 0) ? 1.0 : 0.3 + opacity: (index == 0) ? 1.0 : 0.8 + smooth: true + z: 5 onRouteChanged: { ruler.path = routeData.path; @@ -126,12 +135,13 @@ Item { origin.x: carMarker.width / 2; origin.y: carMarker.height / 2; angle: rotateAngle - } + } } coordinate: ruler.currentPosition anchorPoint.x: carMarker.width / 2 anchorPoint.y: carMarker.height / 2 + z: 12 Location { id: previousCarLocation @@ -146,7 +156,7 @@ Item { } } - //add route view in the map + // Add route view in the map function updateRoute() { routeQuery.clearWaypoints(); routeQuery.addWaypoint(startMarker.coordinate); @@ -155,7 +165,7 @@ Item { map.addMapItem(endMarker) } - //clear route view in the map + // Clear route view in the map function clearRoute() { routeQuery.clearWaypoints(); routeModel.reset(); @@ -171,8 +181,8 @@ Item { var i = 0; var alldistance = ruler.distance * 1000; - if((routeModel.status === RouteModel.Ready) - && (routeModel.count === 1)) + if((routeModel.status === RouteModel.Ready) && + (routeModel.count === 1)) { // XXX: Use car speed in meters to pre-warn the turn instruction while (total < ruler.currentDistance && i < routeModel.get(0).segments.length) @@ -180,14 +190,14 @@ Item { total += routeModel.get(0).segments[i++].maneuver.distanceToNextInstruction; } - //show the tbt board(it will be always show when demo start) + // Show the tbt board (it will be always shown when demo start) tbt_board.visible = true - // Set turn instruction + // Set turn instruction tbt_board.do_setTurnInstructions(routeModel.get(0).segments[i].maneuver.instructionText) tbt_board.state = routeModel.get(0).segments[i].maneuver.direction - //when goto the last instruction,set the states to "arriveDest" + // When goto the last instruction, set the state to "arriveDest" if(i >= (routeModel.get(0).segments.length-1)) { total = alldistance; @@ -199,15 +209,15 @@ Item { // Set distance tbt_board.do_setDistance(dis) - // Set board status + // Set board status if(dis < mapWindow.disOffset && i < routeModel.get(0).segments.length) { - //show the tbt board(the big one) + // Show the full-size tbt board tbt_board.do_showTbtboard(true) - } + } else { - //disvisible the tbt board(the big one) + // Hide the full-size tbt board tbt_board.do_showTbtboard(false) } } @@ -215,22 +225,13 @@ Item { } } - //the route view display by RouteModel + // The route view display by RouteModel RouteModel { id: routeModel + plugin: map.plugin autoUpdate: true query: routeQuery - - plugin: Plugin { - name: "mapbox" - - // Development access token, do not use in production. - PluginParameter { - name: "mapbox.access_token" - value: fileOperation.getMapAccessToken() - } - } } RouteQuery { @@ -238,46 +239,56 @@ Item { } Component.onCompleted: { - //request the route info when map load finish + // Request route info when map load finishes if (ruler) { ruler.initRouteInfo(); ruler.setCurrentPosition(fileOperation.getStartLatitude(), fileOperation.getStartLongitute()); } } - //the functions can be called by outside - //add route signal function + // + // Externally callable functions + // + + // Handle add route signal function do_addRoutePoint(poi_Lat_s, poi_Lon_s, poi_Lat_e, poi_Lon_e) { - //set the startPoint and endPoint + // Set the startPoint and endPoint startPoint= QtPositioning.coordinate(poi_Lat_s,poi_Lon_s); endPoint = QtPositioning.coordinate(poi_Lat_e,poi_Lon_e); startMarker.coordinate = startPoint; endMarker.coordinate = endPoint; - //update the route view + + // Update the route view if (map) { map.updateRoute(); } } - //set the current position + // Set the current position function do_setCoordinate(latitude,longitude,direction,distance) { ruler.setCurrentPosition(latitude, longitude); ruler.setCurrentDistance(distance); } - //stop navidemo signal + // Handle stop navidemo signal function do_stopnavidemo() { - //disvisible the tbt board + // Hide the tbt board tbt_board.visible = false - //clear the routeview + + // Clear the route view if (map) { map.clearRoute(); } } - //arrvice the destination signal - function do_arrivedest(){ - //disvisible the tbt board + // Handle arrive at destination signal + function do_arrivedest() { + // Hide the tbt board tbt_board.visible = false + + // Clear the route view + if (map) { + map.clearRoute(); + } } } |