不显示 MapQuickItem
MapQuickItem is not displayed
我是 Qt 的新手,我正在使用 QML 开始一个新的 GUI。
我有一张地图,我想显示一个标记。但是我无法使用 MapQuickItem 显示标记。
在我标题下面的代码中,地图和MapCircle显示正确,但是MapQuickItem没有显示。
图片 "marker.png" 存在,我可以显示它。
感谢您的帮助。
import QtQuick 2.0
import QtLocation 5.6
import QtPositioning 5.6
import "../items"
SimpleTile {
m_width : 300
m_height : 300
property double m_latitude;
property double m_longitude;
innerObject: Column {
id: colMap
anchors.fill: parent
Plugin {
id: mapPlugin
name: "esri"
}
Text {
id: title
width: colMap.width
height: 25
horizontalAlignment: TextInput.AlignHCenter
font.bold: true
font.pointSize: 15
text: "Position"
}
Map {
id: map
width: colMap.width
height: parent.height - title.height
plugin: mapPlugin
center: QtPositioning.coordinate(m_latitude, m_longitude)
zoomLevel: 14
MapQuickItem {
id: marker
anchorPoint.x: image.width/2
anchorPoint.y: image.height
coordinate {
latitude: m_latitude
longitude: m_longitude
}
sourceItem: Image { id: image; source: "qrc:/images/marker.png" }
}
MapCircle {
radius: 1000
color: "red"
opacity: 0.4
center {
latitude: m_latitude
longitude: m_longitude
}
}
}
}
}
好的,我通过更改
解决了我的问题
...
MapQuickItem {
...
coordinate {
latitude: m_latitude
longitude: m_longitude
}
...
至
...
MapQuickItem {
...
coordinate: QtPositioning.coordinate(m_latitude, m_longitude)
...
感谢您的回答。
我是 Qt 的新手,我正在使用 QML 开始一个新的 GUI。
我有一张地图,我想显示一个标记。但是我无法使用 MapQuickItem 显示标记。
在我标题下面的代码中,地图和MapCircle显示正确,但是MapQuickItem没有显示。
图片 "marker.png" 存在,我可以显示它。
感谢您的帮助。
import QtQuick 2.0 import QtLocation 5.6 import QtPositioning 5.6 import "../items" SimpleTile { m_width : 300 m_height : 300 property double m_latitude; property double m_longitude; innerObject: Column { id: colMap anchors.fill: parent Plugin { id: mapPlugin name: "esri" } Text { id: title width: colMap.width height: 25 horizontalAlignment: TextInput.AlignHCenter font.bold: true font.pointSize: 15 text: "Position" } Map { id: map width: colMap.width height: parent.height - title.height plugin: mapPlugin center: QtPositioning.coordinate(m_latitude, m_longitude) zoomLevel: 14 MapQuickItem { id: marker anchorPoint.x: image.width/2 anchorPoint.y: image.height coordinate { latitude: m_latitude longitude: m_longitude } sourceItem: Image { id: image; source: "qrc:/images/marker.png" } } MapCircle { radius: 1000 color: "red" opacity: 0.4 center { latitude: m_latitude longitude: m_longitude } } } } }
好的,我通过更改
解决了我的问题... MapQuickItem { ... coordinate { latitude: m_latitude longitude: m_longitude } ...
至
... MapQuickItem { ... coordinate: QtPositioning.coordinate(m_latitude, m_longitude) ...
感谢您的回答。