MapItemGroup QML Type
MapItemGroup 유형은 지도 항목을 담는 컨테이너입니다. 더 보기...
| Import Statement: | import QtLocation 6.12 |
| Since: | QtLocation 5.9 |
- 상속된 멤버를 포함한 모든 멤버 목록
- MapItemGroup은 QML Maps 플러그인의 일부입니다.
상세 설명
이 타입의 목적은 서로 관련된 지도 요소와 관련 바인딩을 포함하는 qml 파일을 사용할 수 있도록 하여 코드의 모듈화를 가능하게 하는 것입니다.
참고: Qt 5.9에 포함된 이 API는 기술 미리보기(Technology Preview)버전입니다 .
사용 예
다음 코드 조각은 MapItemGroup을 사용하여 (63, -18) 좌표를 중심으로 반경 100km, 내부 색상은 빨간색, 바깥쪽은 물결 모양의 녹색 테두리로 둘러싸인 다각형( MapCircle)을 만드는 방법을 보여줍니다. 이 두 요소는 모두 반투명한 파란색 원 안에 포함되어 있으며, 그룹 전체를 이동시키는 MouseArea 가 적용되어 있습니다. 이 그룹은 PolygonGroup.qml이라는 별도의 파일에서 정의됩니다:
import QtQuick
import QtPositioning
import QtLocation
MapItemGroup {
id: itemGroup
property alias position: mainCircle.center
property var radius: 100 * 1000
property var borderHeightPct : 0.3
MapCircle {
id: mainCircle
center : QtPositioning.coordinate(40, 0)
radius: itemGroup.radius * (1.0 + borderHeightPct)
opacity: 0.05
visible: true
color: 'blue'
MouseArea{
anchors.fill: parent
drag.target: parent
id: maItemGroup
}
}
MapCircle {
id: groupCircle
center: itemGroup.position
radius: itemGroup.radius
color: 'crimson'
onCenterChanged: {
groupPolyline.populateBorder();
}
}
MapPolyline {
id: groupPolyline
line.color: 'green'
line.width: 3
function populateBorder() {
groupPolyline.path = [] // clearing the path
var waveLength = 8.0;
var waveAmplitude = groupCircle.radius * borderHeightPct;
for (var i=0; i <= 360; i++) {
var wavePhase = (i/360.0 * 2.0 * Math.PI )* waveLength
var waveHeight = (Math.cos(wavePhase) + 1.0) / 2.0
groupPolyline.addCoordinate(groupCircle.center.atDistanceAndAzimuth(groupCircle.radius + waveAmplitude * waveHeight , i))
}
}
Component.onCompleted: {
populateBorder()
}
}
}이제 PolygonGroup.qml은 재사용 가능한 컴포넌트가 되었으며, 지도(Map)에서 다음과 같이 사용할 수 있습니다:
Map {
id: map
PolygonGroup {
id: polygonGroup
position: QtPositioning.coordinate(63,-18)
}
}
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.