MapItemGroup QML Type
맵 항목 그룹 유형은 맵 항목의 컨테이너입니다. 더 보기...
Import Statement: | import QtLocation 6.8 |
Since: | QtLocation 5.9 |
- 상속된 멤버를 포함한 모든 멤버 목록
- MapItemGroup은 QML 맵 플러그인의 일부입니다.
상세 설명
그 목적은 서로 관련된 맵 요소와 관련 바인딩이 포함된 QML 파일을 사용할 수 있도록 하여 코드 모듈화를 가능하게 하는 것입니다.
참고: 이 API는 Qt 5.9에서 기술 프리뷰 버전으로 출시되었습니다.
사용 예
다음 코드 조각은 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 { id: map PolygonGroup { id: polygonGroup position: QtPositioning.coordinate(63,-18) } }
© 2025 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.