Skip to content
QtWS25 Last Chance
  • 0 Votes
    1 Posts
    608 Views
    No one has replied
  • 0 Votes
    2 Posts
    343 Views
    SGaistS
    Hi, If you want to use a member function, the array you pass to the map method must contain items of that class.
  • How to ensure Popup is visible inside a QML Map

    Solved QML and Qt Quick qml map openstreetmaps
    2
    0 Votes
    2 Posts
    448 Views
    M
    After looking for a while, I finally came across these two functions: mapToItem and mapFromItem. So, I first need to map the current item point to the map item coordinate system. Then, I must check the point is inside the map viewport. If not, I have to adjust the coordinate, and after that, I map the point back to the current item coordinate system. Popup width and height seem to decrease when approaching bottom and right borders, so I had to use contentHeight, contentWidth and padding properties to get the real popup size. And I had to initialize the popup x and y to a value different of zero to allow mouse event to pass on the blue dot. Here is the working code, for those who may need it. import QtQuick 2.11 import QtQuick.Controls 2.4 import QtLocation 5.11 import QtPositioning 5.11 import QtQuick.Window 2.11 Window { id: root; width: 800; height: 600; Plugin { id: mapPlugin; name: "osm"; } ListModel { id: myModel ListElement { latitude: 48.2351164; longitude: 6.8986936; name: "The point on the center"; } ListElement { latitude: 48.235111272600186; longitude: 6.9007217756551995; name: "The point on the right"; } ListElement { latitude: 48.23512783507458; longitude: 6.896574932520792; name: "The point on the left"; } ListElement { latitude: 48.23614708436043; longitude: 6.898623901851295; name: "The point on the top"; } ListElement { latitude: 48.23417574713512; longitude: 6.898641104398024; name: "The point on the bottom"; } } Map { id: map anchors.fill: parent plugin: mapPlugin center: QtPositioning.coordinate(48.2351164, 6.8986936) zoomLevel: 19 MapItemView { model: myModel delegate: MapQuickItem { anchorPoint.x: myRect.width / 2 anchorPoint.y: myRect.height / 2 width: myRect.width height: myRect.height coordinate: QtPositioning.coordinate(model.latitude, model.longitude) sourceItem: Rectangle { id: myRect readonly property int radius: 10 width: radius * 2 height: radius * 2 color: "transparent" Canvas { id: myCanvas anchors.fill: parent property alias textVisible: myPopup.visible onPaint: { var width = myRect.width; var height = myRect.height; var centreX = width / 2; var centreY = height / 2; var ctx = getContext("2d"); ctx.reset(); ctx.fillStyle = "blue"; ctx.globalAlpha = 1; ctx.beginPath(); ctx.moveTo(centreX, centreY); ctx.arc(centreX, centreY, myRect.radius, 0, Math.PI * 2, false); ctx.closePath(); ctx.fill(); } MouseArea { x: 0; y: 0; width: myRect.radius * 2 height: myRect.radius * 2 acceptedButtons: Qt.LeftButton hoverEnabled: true onPositionChanged: { myCanvas.textVisible = true; // absolute position in map coordinate system var absPos = mapToItem(map, mouse.x, mouse.y); // margin between mouse pointer and the popup var cursorMargin = 10; // extra margin for right and bottom side var bottomRightSideExtraMargin = 10; // add the cursor margin to the position var absPopupX = absPos.x + cursorMargin; var absPopupY = absPos.y + cursorMargin; // adjust if the popup is out of view on the bottom or right sides if (absPos.x + myPopup.contentWidth + myPopup.leftPadding + myRect.radius * 2 + bottomRightSideExtraMargin > root.width) { absPopupX = root.width - (myPopup.contentWidth + myPopup.leftPadding + cursorMargin + bottomRightSideExtraMargin); } if (absPos.y + myPopup.contentHeight + myPopup.topPadding + myRect.radius * 2 + bottomRightSideExtraMargin > root.height) { absPopupY = root.height - (myPopup.contentHeight + myPopup.topPadding + cursorMargin + bottomRightSideExtraMargin); } // convert back to the current item coordinate system var popupPos = mapFromItem(map, absPopupX, absPopupY); myPopup.x = popupPos.x; myPopup.y = popupPos.y; } onExited: { myCanvas.textVisible = false; } } } Popup { id: myPopup // original offset to allow mouse hover x: 20; y: 20; visible: false Label { text: model.name; horizontalAlignment: Text.AlignHCenter; } } } } } } }
  • QNetworkConfiguration in ligtmap example

    Unsolved General and Desktop qt5 map configuration
    3
    0 Votes
    3 Posts
    471 Views
    Christian EhrlicherC
    And please use the code-tags to make your code readable!
  • Tiles and Open Street Map

    Unsolved General and Desktop qt5 map tiles
    5
    -1 Votes
    5 Posts
    727 Views
    D
    @Christian-Ehrlicher Okey, thank you
  • Offline Mapping

    Unsolved General and Desktop qt5 osm map tiles
    14
    0 Votes
    14 Posts
    2k Views
    Christian EhrlicherC
    @jsulm said in Offline Mapping: Which one? It was me. The question was to similar.
  • finding address with geocodemodel

    Unsolved General and Desktop qt5 map qml
    6
    0 Votes
    6 Posts
    818 Views
    raven-worxR
    @suslucoder so again, where does Location come from then. Tokens starting with a capital letter have a special meaning in QML
  • Qt Location, Map Cache

    Unsolved General and Desktop qt5 map cache disk cache
    7
    0 Votes
    7 Posts
    1k Views
    D
    @raven-worx thank you
  • Declare multiple png's on a path

    Unsolved General and Desktop map qt5 location
    4
    0 Votes
    4 Posts
    561 Views
    jsulmJ
    @suslucoder said in Declare multiple png's on a path: Doesnt it contains 3 png? No You should check the code to see what it does with that string. %1, %2... are used to format string, see https://doc.qt.io/qt-5/qstring.html#arg
  • How can I mark my current position?

    Unsolved General and Desktop qt5 map qml
    4
    0 Votes
    4 Posts
    593 Views
    ODБOïO
    @suslucoder please have a look here https://doc.qt.io/qt-5/qtpositioning-index.html
  • 0 Votes
    1 Posts
    621 Views
    No one has replied
  • 0 Votes
    1 Posts
    305 Views
    No one has replied
  • App Like Uber

    Locked Unsolved Mobile and Embedded map android
    5
    0 Votes
    5 Posts
    831 Views
    SGaistS
    There's the QtLocation and QtPositioning modules that should give you starting point.
  • 0 Votes
    2 Posts
    498 Views
    0
    I know I'm too late, but...I was also interested in this problem and found the following in the qt source code: The difference between a GeoMapObject and a MapItem is twofold. First, GeoMapObject are always backed by a plugin-specific implementation and do not come with a default implementation. If a plugin does not support a specific GeoMapObject type, adding such a GeoMapObject will have no effect. Second, GeoMapObject are not QQuickItems, thus being a much more lightweight way to add content to a map. GeoMapObject support is plugin-dependent, and is documented per plugin.
  • 0 Votes
    2 Posts
    1k Views
    sierdzioS
    Use a separate QObject-derived class and set it as context property. Other options: https://doc.qt.io/qt-5/qtqml-cppintegration-topic.html https://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html
  • locating coordinates in Qt qml offline map

    Unsolved QML and Qt Quick qml map coordinate offline
    2
    0 Votes
    2 Posts
    602 Views
    H
    @hem1 hi, I know I has been so long but did you find any ways
  • Qt offline maps using osm tiles

    Unsolved QML and Qt Quick qml map offline qtlocation osm
    12
    1 Votes
    12 Posts
    10k Views
    P
    @vpanchal @raven-worx Hi I've tried: file:///home/dev/Downloads/OsmOffline/offline_tiles/ This does not work. Am I doing something wrong? Did it work for you?
  • QT Location Map interaction/slots

    Unsolved General and Desktop map location slots
    1
    0 Votes
    1 Posts
    443 Views
    No one has replied
  • 0 Votes
    1 Posts
    461 Views
    No one has replied