diff options
Diffstat (limited to 'examples/location/mapviewer/map')
-rw-r--r-- | examples/location/mapviewer/map/CircleItem.qml | 28 | ||||
-rw-r--r-- | examples/location/mapviewer/map/ImageItem.qml | 32 | ||||
-rw-r--r-- | examples/location/mapviewer/map/MapComponent.qml | 134 | ||||
-rw-r--r-- | examples/location/mapviewer/map/PolygonItem.qml | 32 | ||||
-rw-r--r-- | examples/location/mapviewer/map/PolylineItem.qml | 30 | ||||
-rw-r--r-- | examples/location/mapviewer/map/RectangleItem.qml | 29 |
6 files changed, 53 insertions, 232 deletions
diff --git a/examples/location/mapviewer/map/CircleItem.qml b/examples/location/mapviewer/map/CircleItem.qml deleted file mode 100644 index a5cae752..00000000 --- a/examples/location/mapviewer/map/CircleItem.qml +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick -import QtLocation - -MapCircle { - - color: "#da5546" - border.color: "#330a0a" - border.width: 2 - smooth: true - opacity: 0.75 - - function setGeometry(anchorCoordinate) { - center = anchorCoordinate - } - - function addGeometry(newCoordinate, changeLast){ - radius = center.distanceTo(newCoordinate) - return true - } - - function finishAddGeometry(){ - color = "#46a2da" - border.color = "#190a33" - opacity = 0.25 - } -} diff --git a/examples/location/mapviewer/map/ImageItem.qml b/examples/location/mapviewer/map/ImageItem.qml deleted file mode 100644 index 433b12ef..00000000 --- a/examples/location/mapviewer/map/ImageItem.qml +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick -import QtLocation - -MapQuickItem { //to be used inside MapComponent only - id: imageItem - - anchorPoint.x: testImage.width/2 - anchorPoint.y: testImage.height/2 - - function setGeometry(anchorCoordinate) { - coordinate = anchorCoordinate - } - - function addGeometry(newCoordinate, changeLast){ - var p1 = view.map.fromCoordinate(coordinate, false); - var p2 = view.map.fromCoordinate(newCoordinate, false); - var size = Math.max(Math.abs((p1.x-p2.x)), Math.abs((p1.y-p2.y))); - testImage.scale = Math.max(0.1, size/Math.max(testImage.height, testImage.width))*2 - return true - } - - function finishAddGeometry(){ - } - - sourceItem: Image { - id: testImage - source: "../resources/icon.png" - opacity: 0.7 - } -} diff --git a/examples/location/mapviewer/map/MapComponent.qml b/examples/location/mapviewer/map/MapComponent.qml index 149c0e47..6f887536 100644 --- a/examples/location/mapviewer/map/MapComponent.qml +++ b/examples/location/mapviewer/map/MapComponent.qml @@ -20,7 +20,6 @@ MapView { property alias routeModel: routeModel property alias geocodeModel: geocodeModel property alias slidersExpanded: sliders.expanded - property variant unfinishedItem: 'undefined' signal showGeocodeInfo() signal geocodeFinished() @@ -97,15 +96,6 @@ MapView { view.markers = [] } - function deleteMapItems() - { - var count = view.mapItems.length - for (var i = count-1; i>=0; i--){ - view.map.removeMapItem(view.mapItems[i]) - } - view.mapItems = [] - } - function addMarker() { var count = view.markers.length @@ -117,21 +107,6 @@ MapView { markers.push(marker) } - function addGeoItem(item) - { - var count = view.map.mapItems.length - var co = Qt.createComponent(item+'.qml') - if (co.status === Component.Ready) { - unfinishedItem = co.createObject(map) - unfinishedItem.setGeometry(tapHandler.lastCoordinate) - unfinishedItem.addGeometry(hoverHandler.currentCoordinate, false) - view.map.addMapItem(unfinishedItem) - mapItems.push(unfinishedItem) - } else { - console.log(item + " is not supported right now, please call us later.") - } - } - function deleteMarker(index) { //update list of markers @@ -248,20 +223,9 @@ MapView { var mapCenterPoint = Qt.point(view.map.width / 2.0 - dx, view.map.height / 2.0 - dy); view.map.center = view.map.toCoordinate(mapCenterPoint); - } else if (event.key === Qt.Key_Escape) { - mapview.unfinishedItem.finishAddGeometry() - mapview.unfinishedItem = 'undefined' } } - /* @todo - Binding { - target: map - property: 'center' - value: positionSource.position.coordinate - when: followme - }*/ - PositionSource{ id: positionSource active: followme @@ -272,6 +236,30 @@ MapView { } MapQuickItem { + id: mePoisition + parent: view.map + sourceItem: Rectangle { width: 14; height: 14; color: "#251ee4"; border.width: 2; border.color: "white"; smooth: true; radius: 7 } + coordinate: positionSource.position.coordinate + opacity: 1.0 + anchorPoint: Qt.point(sourceItem.width/2, sourceItem.height/2) + visible: followme + } + MapQuickItem { + parent: view.map + sourceItem: Text{ + text: qsTr("You're here!") + color:"#242424" + font.bold: true + styleColor: "#ECECEC" + style: Text.Outline + } + coordinate: positionSource.position.coordinate + anchorPoint: Qt.point(-mePoisition.sourceItem.width * 0.5, mePoisition.sourceItem.height * 1.5) + visible: followme + } + + + MapQuickItem { id: poiTheQtComapny parent: view.map sourceItem: Rectangle { width: 14; height: 14; color: "#e41e25"; border.width: 2; border.color: "white"; smooth: true; radius: 7 } @@ -293,7 +281,7 @@ MapView { style: Text.Outline } coordinate: poiTheQtComapny.coordinate - anchorPoint: Qt.point(-poiTheQtComapny.sourceItem.width * 0.5,poiTheQtComapny.sourceItem.height * 1.5) + anchorPoint: Qt.point(-poiTheQtComapny.sourceItem.width * 0.5, poiTheQtComapny.sourceItem.height * 1.5) } MapSliders { @@ -412,29 +400,37 @@ MapView { Component { id: pointDelegate - MapCircle { + MapQuickItem { id: point parent: view.map - radius: 1000 - color: "#46a2da" - border.color: "#190a33" - border.width: 2 - smooth: true - opacity: 0.25 - center: locationData.coordinate - //! [pointdel0] - /* TapHandler { - point.onPositionChanged: { - if (Math.abs(view.map.pressX - parent.x - point.position.x) > view.map.jitterThreshold || - Math.abs(view.map.pressY - parent.y - point.position.y) > view.map.jitterThreshold) { - if (pressed) - parent.radius = parent.center.distanceTo(view.map.toCoordinate(point.position)) - } + coordinate: locationData.coordinate + + sourceItem: Image { + id: pointMarker + source: "../resources/marker_blue.png" + //! [pointdel0] + + Text{ + id: pointText + anchors.bottom: pointMarker.top + anchors.horizontalCenter: pointMarker.horizontalCenter + text: locationData.address.street + ", " + locationData.address.city + color:"#242424" + font.bold: true + styleColor: "#ECECEC" + style: Text.Outline } - onLongPressed: showPointMenu(view.map.toCoordinate(point.position)) - }*/ - //! [pointdel1] + } + smooth: true + autoFadeIn: false + anchorPoint.x: pointMarker.width/4 + anchorPoint.y: pointMarker.height + + TapHandler { + onLongPressed: showPointMenu(point.coordinate) + //! [pointdel1] + } } } //! [pointdel1] @@ -464,19 +460,6 @@ MapView { onTriggered: view.calculateScale() } - HoverHandler { - id: hoverHandler - property variant currentCoordinate - grabPermissions: PointerHandler.CanTakeOverFromItems | PointerHandler.CanTakeOverFromHandlersOfDifferentType - - onPointChanged: { - currentCoordinate = view.map.toCoordinate(hoverHandler.point.position) - if (mapview.unfinishedItem !== 'undefined') - mapview.unfinishedItem.addGeometry(view.map.toCoordinate(hoverHandler.point.position), true) - } - - } - TapHandler { id: tapHandler property variant lastCoordinate @@ -490,18 +473,7 @@ MapView { onSingleTapped: (eventPoint, button) => { if (button === Qt.RightButton) { - if (mapview.unfinishedItem !== 'undefined') { - mapview.unfinishedItem.finishAddGeometry() - mapview.unfinishedItem = 'undefined' - } else - showMainMenu(lastCoordinate) - } else if (button === Qt.LeftButton) { - if (mapview.unfinishedItem !== 'undefined') { - if (mapview.unfinishedItem.addGeometry(view.map.toCoordinate(tapHandler.point.position), false)) { - mapview.unfinishedItem.finishAddGeometry() - mapview.unfinishedItem = 'undefined' - } - } + showMainMenu(lastCoordinate) } } diff --git a/examples/location/mapviewer/map/PolygonItem.qml b/examples/location/mapviewer/map/PolygonItem.qml deleted file mode 100644 index d9a2be99..00000000 --- a/examples/location/mapviewer/map/PolygonItem.qml +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick -import QtLocation - -MapPolygon { - - color: "#da5546" - border.color: "#330a0a" - border.width: 2 - smooth: true - opacity: 0.75 - - function setGeometry(anchorCoordinate){ - addCoordinate(anchorCoordinate) - } - - function addGeometry(newCoordinate, changeLast){ - if (changeLast && path.length > 0) - removeCoordinate(path[path.length-1]) - addCoordinate(newCoordinate) - return false - } - - function finishAddGeometry(){ - if (path.length > 0) - removeCoordinate(path[path.length-1]) - color = "#46a2da" - border.color = "#190a33" - opacity = 0.25 - } -} diff --git a/examples/location/mapviewer/map/PolylineItem.qml b/examples/location/mapviewer/map/PolylineItem.qml deleted file mode 100644 index 727ce973..00000000 --- a/examples/location/mapviewer/map/PolylineItem.qml +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick -import QtLocation - -MapPolyline { - - line.color: "#330a0a" - line.width: 4 - opacity: 0.75 - smooth: true - - function setGeometry(anchorCoordinate){ - addCoordinate(anchorCoordinate) - } - - function addGeometry(newCoordinate, changeLast){ - if (changeLast) - replaceCoordinate(pathLength()-1, newCoordinate) - else - addCoordinate(newCoordinate) - return false - } - - function finishAddGeometry(){ - removeCoordinate(pathLength()-1) - line.color = "#46a2da" - opacity = 0.25 - } -} diff --git a/examples/location/mapviewer/map/RectangleItem.qml b/examples/location/mapviewer/map/RectangleItem.qml deleted file mode 100644 index 85d91a6f..00000000 --- a/examples/location/mapviewer/map/RectangleItem.qml +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick -import QtLocation - -MapRectangle { - id: mapRectangle - - color: "#da5546" - border.color: "#330a0a" - border.width: 2 - smooth: true - opacity: 0.75 - - function setGeometry(anchorCoordinate) { - topLeft = anchorCoordinate - } - - function addGeometry(newCoordinate, changeLast){ - bottomRight = newCoordinate - return true //finished - } - - function finishAddGeometry(){ - color = "#46a2da" - border.color = "#190a33" - opacity = 0.25 - } -} |