Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. MapItemView does not show Route

MapItemView does not show Route

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 428 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mario84
    wrote on last edited by
    #1

    Hi,

    I was playing around with QtQuick Maps and stuff and tried to display a route on a Map. I was able to do basic things like displaying the Map, centering it on a specific coordinate, zooming it and so on without much trouble, but displaying a Route just won't work.

    As far as I understood the documentation, what I did should work. But the docs are not super detailed about this topic.

    I reduced my code to a minimal example, which should just display a small route in Berlin:

    import QtQuick 2.7
    import QtQuick.Controls 2.0
    import QtQuick.Layouts 1.0
    import QtLocation 5.3
    import QtPositioning 5.3
    
    ApplicationWindow {
    	visible: true
    	width: 1000
    	height: 700
    
    	Plugin {
    		id: thePlugin
    		name: "mapbox"
    
    		PluginParameter {
    			name: "mapbox.access_token"
    			value: "MY_PRIVATE_MAPBOX_KEY"
    		}
    
    		PluginParameter {
    			name: "mapbox.map_id"
    			value: "mapbox.mapbox-streets-v6"
    		}
    	}
    
    	Map {
    		id: theMap
    
    		plugin: thePlugin
    		anchors.fill: parent
    
    		zoomLevel: maximumZoomLevel - 2
    		center: QtPositioning.coordinate(52.5152725, 13.3774632)
    
    		RouteQuery {
    			id: rQuery
    		}
    
    		RouteModel {
    			id: rModel
    
    			plugin: thePlugin
    			query: rQuery
    		}
    
    		Component {
    			id: rDelegate
    
    			MapRoute {
    				route: routeData
    				line.color: "yellow"
    				line.width: 10
    				smooth: true
    			}
    		}
    
    		MapItemView {
    			model: rModel
    			delegate: rDelegate
    
    			Component.onCompleted: {
    				rQuery.clearWaypoints();
    				rQuery.addWaypoint(QtPositioning.coordinate(52.5152725, 13.3774632));
    				rQuery.addWaypoint(QtPositioning.coordinate(52.5196863, 13.4040609));
    				rQuery.travelModes = RouteQuery.PedestrianTravel;
    				rModel.update();
    			}
    		}
    	}
    }
    

    I'd be glad, if somebody could have a look and tell me what I'm doing wrong...

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved