2017-07-17 02:04:05 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2017-07-14 17:53:08 +03:00
|
|
|
import QtQuick 2.0
|
|
|
|
import QtLocation 5.3
|
|
|
|
import QtPositioning 5.3
|
2017-07-16 03:01:54 +03:00
|
|
|
import org.subsurfacedivelog.mobile 1.0
|
2017-07-14 17:53:08 +03:00
|
|
|
|
2017-07-15 00:55:29 +03:00
|
|
|
Item {
|
2017-07-20 00:09:53 +03:00
|
|
|
readonly property var esriMapTypeIndexes: { "STREET": 0, "SATELLITE": 1 }
|
2017-07-16 00:56:54 +03:00
|
|
|
|
2017-07-14 17:53:08 +03:00
|
|
|
Plugin {
|
|
|
|
id: mapPlugin
|
|
|
|
name: "esri"
|
|
|
|
}
|
|
|
|
|
2017-07-16 03:01:54 +03:00
|
|
|
MapWidgetHelper {
|
|
|
|
id: mapHelper
|
2017-07-16 23:59:09 +03:00
|
|
|
map: map
|
2017-07-16 03:01:54 +03:00
|
|
|
}
|
|
|
|
|
2017-07-14 17:53:08 +03:00
|
|
|
Map {
|
2017-07-16 00:56:54 +03:00
|
|
|
id: map
|
2017-07-14 17:53:08 +03:00
|
|
|
anchors.fill: parent
|
|
|
|
plugin: mapPlugin
|
|
|
|
zoomLevel: 1
|
2017-07-16 00:56:54 +03:00
|
|
|
|
2017-07-20 00:09:53 +03:00
|
|
|
readonly property var defaultCenter: QtPositioning.coordinate(0, 0)
|
|
|
|
readonly property var defaultZoomIn: 17.0
|
2017-07-20 00:22:52 +03:00
|
|
|
readonly property var defaultZoomOut: 2.0
|
2017-07-20 00:09:53 +03:00
|
|
|
property var newCenter: defaultCenter
|
|
|
|
property var newZoom: 1.0
|
2017-07-17 01:16:27 +03:00
|
|
|
|
2017-07-16 00:56:54 +03:00
|
|
|
Component.onCompleted: {
|
2017-07-20 00:28:44 +03:00
|
|
|
activeMapType = supportedMapTypes[esriMapTypeIndexes.SATELLITE]
|
2017-07-16 00:56:54 +03:00
|
|
|
}
|
2017-07-17 00:25:19 +03:00
|
|
|
|
2017-07-17 22:24:30 +03:00
|
|
|
MapItemView {
|
|
|
|
id: mapItemView
|
|
|
|
model: mapHelper.model
|
|
|
|
delegate: MapQuickItem {
|
|
|
|
anchorPoint.x: 0
|
|
|
|
anchorPoint.y: mapItemImage.height
|
2017-07-17 22:36:55 +03:00
|
|
|
coordinate: model.coordinate
|
2017-07-19 23:51:39 +03:00
|
|
|
z: mapHelper.model.selectedUuid === model.uuid ? mapHelper.model.count - 1 : 0
|
2017-07-19 02:36:59 +03:00
|
|
|
sourceItem: Image {
|
2017-07-20 00:09:53 +03:00
|
|
|
id: mapItemImage
|
|
|
|
source: "qrc:///mapwidget-marker" + (mapHelper.model.selectedUuid === model.uuid ? "-selected" : "")
|
2017-07-20 00:06:08 +03:00
|
|
|
|
|
|
|
SequentialAnimation {
|
2017-07-20 00:09:53 +03:00
|
|
|
id: mapItemImageAnimation
|
2017-07-20 00:06:08 +03:00
|
|
|
PropertyAnimation {
|
|
|
|
target: mapItemImage; property: "scale"; from: 1.0; to: 0.7; duration: 120;
|
|
|
|
}
|
|
|
|
PropertyAnimation {
|
|
|
|
target: mapItemImage; property: "scale"; from: 0.7; to: 1.0; duration: 80;
|
|
|
|
}
|
|
|
|
}
|
2017-07-19 02:36:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
|
|
|
mapHelper.model.selectedUuid = model.uuid
|
2017-07-20 00:39:19 +03:00
|
|
|
mapItemImageAnimation.restart()
|
2017-07-19 02:36:59 +03:00
|
|
|
}
|
|
|
|
}
|
2017-07-17 22:24:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-17 01:16:27 +03:00
|
|
|
ParallelAnimation {
|
|
|
|
id: mapAnimation
|
|
|
|
CoordinateAnimation {
|
|
|
|
target: map
|
|
|
|
property: "center"
|
|
|
|
to: map.newCenter
|
|
|
|
duration: 2000
|
|
|
|
}
|
|
|
|
NumberAnimation {
|
|
|
|
target: map
|
|
|
|
property: "zoomLevel"
|
2017-07-20 00:16:09 +03:00
|
|
|
to: map.newZoom
|
2017-07-17 01:16:27 +03:00
|
|
|
duration: 3000
|
|
|
|
easing.type: Easing.InCubic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-20 00:22:52 +03:00
|
|
|
function animateMapTo(coord, zoom) {
|
2017-07-20 00:28:44 +03:00
|
|
|
newCenter = coord
|
|
|
|
newZoom = zoom
|
2017-07-20 00:09:53 +03:00
|
|
|
mapAnimation.restart()
|
2017-07-20 00:22:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function centerOnMapLocation(mapLocation) {
|
2017-07-20 00:28:44 +03:00
|
|
|
zoomLevel = defaultZoomOut
|
2017-07-20 00:29:42 +03:00
|
|
|
animateMapTo(mapLocation.coordinate, defaultZoomIn)
|
2017-07-20 00:09:53 +03:00
|
|
|
mapHelper.model.selectedUuid = mapLocation.uuid
|
2017-07-17 00:25:19 +03:00
|
|
|
}
|
2017-07-20 00:29:42 +03:00
|
|
|
|
|
|
|
function deselectMapLocation() {
|
|
|
|
mapHelper.model.selectedUuid = 0
|
|
|
|
animateMapTo(defaultCenter, defaultZoomOut)
|
|
|
|
}
|
2017-07-14 17:53:08 +03:00
|
|
|
}
|
|
|
|
}
|