Created
October 13, 2017 18:14
-
-
Save am2222/057af8eb729a76b4f09c818de1d0ad24 to your computer and use it in GitHub Desktop.
QML map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**************************************************************************** | |
** | |
** Copyright (C) 2016 The Qt Company Ltd. | |
** Contact: http://www.qt.io/licensing/ | |
** | |
** This file is part of the examples of the Qt Toolkit. | |
** | |
** $QT_BEGIN_LICENSE:BSD$ | |
** You may use this file under the terms of the BSD license as follows: | |
** | |
** "Redistribution and use in source and binary forms, with or without | |
** modification, are permitted provided that the following conditions are | |
** met: | |
** * Redistributions of source code must retain the above copyright | |
** notice, this list of conditions and the following disclaimer. | |
** * Redistributions in binary form must reproduce the above copyright | |
** notice, this list of conditions and the following disclaimer in | |
** the documentation and/or other materials provided with the | |
** distribution. | |
** * Neither the name of The Qt Company Ltd nor the names of its | |
** contributors may be used to endorse or promote products derived | |
** from this software without specific prior written permission. | |
** | |
** | |
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." | |
** | |
** $QT_END_LICENSE$ | |
** | |
****************************************************************************/ | |
import QtQuick 2.0 | |
import QtQuick.Window 2.0 | |
import QtLocation 5.6 | |
import QtPositioning 5.6 | |
import QtGraphicalEffects 1.0 | |
Window { | |
width: 512 | |
height: 512 | |
visible: true | |
Plugin { | |
id: mapPlugin | |
name: "esri" // "mapboxgl", "esri", ... | |
// specify plugin parameters if necessary | |
// PluginParameter { | |
// name: | |
// value: | |
// } | |
} | |
Map { | |
id:map | |
anchors.fill: parent | |
plugin: mapPlugin | |
center: QtPositioning.coordinate(59.91, 10.75) // Oslo | |
zoomLevel: 7 | |
MapPolygon { | |
id: polygon | |
color: 'white' // Any color, only alpha channel will be used | |
path: [ | |
{ latitude: 59, longitude: 10 }, | |
{ latitude: 59.5, longitude: 11 }, | |
{ latitude: 60, longitude: 11.5 }, | |
{ latitude: 59, longitude: 10 } | |
] | |
visible: false | |
} | |
// Image { | |
// id: image2 | |
// source: "qrc:/../../../../../Desktop/1.png" | |
// visible: false // hide it so it does not appear over the masked image | |
// } | |
// OpacityMask // Actual masked image | |
// { | |
// source: image2 | |
// maskSource: polygon | |
// anchors.fill: polygon | |
// } | |
MapQuickItem{ | |
id:yes | |
// anchorPoint.x: image.width/10 | |
// anchorPoint.y: image.height/10 | |
zoomLevel:1 | |
// width: 1 | |
// height: 1 | |
sourceItem: Image { | |
id:image | |
asynchronous:true | |
opacity: 99 | |
source: "qrc:/../../../../../Desktop/1.png" | |
transformOrigin: Item.Center | |
rotation: 0 | |
// scale: 0.25 | |
// width: 500 | |
// height: 200 | |
// sourceSize.width: image.width/2 | |
//visible: false | |
// sourceSize.height:100 | |
MouseArea{ anchors.fill: parent ;onPressed: { console.log(mouse.x + " "+ mouse.y) } } | |
} | |
coordinate: QtPositioning.coordinate(59.91, 10.75) | |
} | |
// MouseArea { | |
// anchors.fill: parent | |
// onPressed: { | |
// // yes.coordinate = map.toCoordinate(Qt.point(mouse.x,mouse.y)); | |
// onPressed: console.log('latitude = '+ (map.toCoordinate(Qt.point(mouse.x,mouse.y)).latitude), | |
// 'longitude = '+ (map.toCoordinate(Qt.point(mouse.x,mouse.y)).longitude)); | |
// } | |
// } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment