2017-07-16 23:04:05 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2017-07-14 14:53:08 +00:00
|
|
|
import QtQuick 2.0
|
|
|
|
import QtLocation 5.3
|
|
|
|
import QtPositioning 5.3
|
2017-07-16 00:01:54 +00:00
|
|
|
import org.subsurfacedivelog.mobile 1.0
|
2017-07-14 14:53:08 +00:00
|
|
|
|
2017-07-14 21:55:29 +00:00
|
|
|
Item {
|
2017-07-14 14:53:08 +00:00
|
|
|
Plugin {
|
|
|
|
id: mapPlugin
|
|
|
|
name: "esri"
|
|
|
|
}
|
|
|
|
|
2017-07-16 00:01:54 +00:00
|
|
|
MapWidgetHelper {
|
|
|
|
id: mapHelper
|
2017-07-16 20:59:09 +00:00
|
|
|
map: map
|
2017-07-16 00:01:54 +00:00
|
|
|
}
|
|
|
|
|
2017-07-14 14:53:08 +00:00
|
|
|
Map {
|
2017-07-15 21:56:54 +00:00
|
|
|
id: map
|
2017-07-14 14:53:08 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
plugin: mapPlugin
|
|
|
|
zoomLevel: 1
|
2017-07-15 21:56:54 +00:00
|
|
|
|
2017-07-19 23:51:34 +00:00
|
|
|
readonly property var mapType: { "STREET": supportedMapTypes[0], "SATELLITE": supportedMapTypes[1] }
|
2017-07-19 21:09:53 +00:00
|
|
|
readonly property var defaultCenter: QtPositioning.coordinate(0, 0)
|
|
|
|
readonly property var defaultZoomIn: 17.0
|
2017-07-19 22:33:15 +00:00
|
|
|
readonly property var defaultZoomOut: 1.0
|
2017-07-19 21:09:53 +00:00
|
|
|
property var newCenter: defaultCenter
|
|
|
|
property var newZoom: 1.0
|
2017-07-16 22:16:27 +00:00
|
|
|
|
2017-07-15 21:56:54 +00:00
|
|
|
Component.onCompleted: {
|
2017-07-19 23:51:34 +00:00
|
|
|
activeMapType = mapType.SATELLITE
|
2017-07-15 21:56:54 +00:00
|
|
|
}
|
2017-07-16 21:25:19 +00:00
|
|
|
|
2017-07-17 19:24:30 +00:00
|
|
|
MapItemView {
|
|
|
|
id: mapItemView
|
|
|
|
model: mapHelper.model
|
|
|
|
delegate: MapQuickItem {
|
|
|
|
anchorPoint.x: 0
|
|
|
|
anchorPoint.y: mapItemImage.height
|
2017-07-17 19:36:55 +00:00
|
|
|
coordinate: model.coordinate
|
2017-07-19 20:51:39 +00:00
|
|
|
z: mapHelper.model.selectedUuid === model.uuid ? mapHelper.model.count - 1 : 0
|
2017-07-18 23:36:59 +00:00
|
|
|
sourceItem: Image {
|
2017-07-19 21:09:53 +00:00
|
|
|
id: mapItemImage
|
|
|
|
source: "qrc:///mapwidget-marker" + (mapHelper.model.selectedUuid === model.uuid ? "-selected" : "")
|
2017-07-19 21:06:08 +00:00
|
|
|
|
|
|
|
SequentialAnimation {
|
2017-07-19 21:09:53 +00:00
|
|
|
id: mapItemImageAnimation
|
2017-07-19 21:06:08 +00: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-18 23:36:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
|
|
|
mapHelper.model.selectedUuid = model.uuid
|
2017-07-19 21:39:19 +00:00
|
|
|
mapItemImageAnimation.restart()
|
2017-07-18 23:36:59 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-17 19:24:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-16 22:16:27 +00:00
|
|
|
ParallelAnimation {
|
2017-07-19 22:33:15 +00:00
|
|
|
id: mapAnimationZoomIn
|
2017-07-16 22:16:27 +00:00
|
|
|
CoordinateAnimation {
|
2017-07-19 22:11:10 +00:00
|
|
|
target: map; property: "center"; to: map.newCenter; duration: 2000;
|
2017-07-16 22:16:27 +00:00
|
|
|
}
|
|
|
|
NumberAnimation {
|
2017-07-19 22:33:15 +00:00
|
|
|
target: map; property: "zoomLevel"; to: map.newZoom ; duration: 3000; easing.type: Easing.InCubic;
|
2017-07-16 22:16:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-19 22:33:15 +00:00
|
|
|
ParallelAnimation {
|
|
|
|
id: mapAnimationZoomOut
|
|
|
|
NumberAnimation {
|
|
|
|
target: map; property: "zoomLevel"; from: map.zoomLevel; to: map.newZoom; duration: 3000;
|
|
|
|
}
|
|
|
|
SequentialAnimation {
|
|
|
|
PauseAnimation { duration: 2000 }
|
|
|
|
CoordinateAnimation {
|
|
|
|
target: map; property: "center"; to: map.newCenter; duration: 2000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function animateMapZoomIn(coord) {
|
|
|
|
zoomLevel = defaultZoomOut
|
2017-07-19 21:28:44 +00:00
|
|
|
newCenter = coord
|
2017-07-19 22:33:15 +00:00
|
|
|
newZoom = map.defaultZoomIn
|
|
|
|
mapAnimationZoomIn.restart()
|
|
|
|
mapAnimationZoomOut.stop()
|
|
|
|
}
|
|
|
|
|
|
|
|
function animateMapZoomOut() {
|
|
|
|
newCenter = map.defaultCenter
|
|
|
|
newZoom = map.defaultZoomOut
|
|
|
|
mapAnimationZoomIn.stop()
|
|
|
|
mapAnimationZoomOut.restart()
|
2017-07-19 21:22:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function centerOnMapLocation(mapLocation) {
|
2017-07-19 21:09:53 +00:00
|
|
|
mapHelper.model.selectedUuid = mapLocation.uuid
|
2017-07-19 22:33:15 +00:00
|
|
|
animateMapZoomIn(mapLocation.coordinate)
|
2017-07-16 21:25:19 +00:00
|
|
|
}
|
2017-07-19 21:29:42 +00:00
|
|
|
|
|
|
|
function deselectMapLocation() {
|
|
|
|
mapHelper.model.selectedUuid = 0
|
2017-07-19 22:33:15 +00:00
|
|
|
animateMapZoomOut()
|
2017-07-19 21:29:42 +00:00
|
|
|
}
|
2017-07-20 02:24:18 +00:00
|
|
|
}
|
2017-07-20 00:07:47 +00:00
|
|
|
|
2017-07-20 02:24:18 +00:00
|
|
|
Image {
|
|
|
|
id: toggleImage
|
|
|
|
x: 10; y: x
|
|
|
|
source: "qrc:///mapwidget-toggle-" + (map.activeMapType === map.mapType.SATELLITE ? "street" : "satellite")
|
2017-07-20 00:13:12 +00:00
|
|
|
|
2017-07-20 02:24:18 +00:00
|
|
|
SequentialAnimation {
|
|
|
|
id: toggleImageAnimation
|
|
|
|
PropertyAnimation {
|
|
|
|
target: toggleImage; property: "scale"; from: 1.0; to: 0.8; duration: 120;
|
2017-07-20 00:13:12 +00:00
|
|
|
}
|
2017-07-20 02:24:18 +00:00
|
|
|
PropertyAnimation {
|
|
|
|
target: toggleImage; property: "scale"; from: 0.8; to: 1.0; duration: 80;
|
|
|
|
}
|
|
|
|
}
|
2017-07-20 00:13:12 +00:00
|
|
|
|
2017-07-20 02:24:18 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
|
|
|
map.activeMapType = map.activeMapType === map.mapType.SATELLITE ? map.mapType.STREET : map.mapType.SATELLITE
|
|
|
|
toggleImageAnimation.restart()
|
2017-07-20 00:07:47 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-14 14:53:08 +00:00
|
|
|
}
|
2017-07-20 13:58:21 +00:00
|
|
|
|
2017-07-21 13:26:33 +00:00
|
|
|
function openLocationInGoogleMaps(latitude, longitude) {
|
|
|
|
var loc = latitude + " " + longitude
|
|
|
|
var url = "https://www.google.com/maps/place/" + loc + "/@" + loc + ",5000m/data=!3m1!1e3!4m2!3m1!1s0x0:0x0"
|
|
|
|
Qt.openUrlExternally(url)
|
|
|
|
}
|
|
|
|
|
2017-07-20 13:58:21 +00:00
|
|
|
MapWidgetContextMenu {
|
|
|
|
id: contextMenu
|
2017-07-20 16:25:59 +00:00
|
|
|
y: 10; x: map.width - y
|
2017-07-20 22:28:58 +00:00
|
|
|
onActionSelected: {
|
|
|
|
// TODO: perform action actions
|
|
|
|
switch (action) {
|
|
|
|
case contextMenu.actions.OPEN_LOCATION_IN_GOOGLE_MAPS:
|
2017-07-21 13:26:33 +00:00
|
|
|
openLocationInGoogleMaps(map.center.latitude, map.center.longitude)
|
2017-07-20 22:28:58 +00:00
|
|
|
break;
|
|
|
|
case contextMenu.actions.COPY_LOCATION_DECIMAL:
|
|
|
|
console.log("COPY_LOCATION_DECIMAL");
|
|
|
|
break;
|
|
|
|
case contextMenu.actions.COPY_LOCATION_SEXAGESIMAL:
|
|
|
|
console.log("COPY_LOCATION_SEXAGESIMAL");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-07-20 13:58:21 +00:00
|
|
|
}
|
2017-07-14 14:53:08 +00:00
|
|
|
}
|