Reputation: 525
I couldn't find any way to set MapCircle's radius to fixed size while zooming map. Marker icons are used in PlaceSearchModel, but I couldn't make it dynamic. When I zoom the map it becomes bigger, when minimizing the map, the marker disappears.
Here is the code:
import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Controls.Material 2.0
import QtQuick.Controls.Universal 2.0
import Fluid.Controls 1.0
import QtLocation 5.6
import QtPositioning 5.6
TabbedPage {
id: frame
title: "Web Map"
Tab {
title: "Map Viewer"
anchors {
left: parent.left
top: parent.top
bottom: parent.bottom
}
width: parent.width
clip: true
Material.background: "white"
Material.elevation: 1
Universal.background: Universal.accent
Plugin {
id: mapPlugin
name: "osm"
}
Map {
id:map
anchors.fill: parent
plugin: mapPlugin
zoomLevel: 14
MapItemView {
model: src
delegate: MapQuickItem {
coordinate: src.position.coordinate
anchorPoint.x: image.width * 0.5
anchorPoint.y: image.height
sourceItem: Column {
Image { id: image; source: "marker.png" }
Text { text: title; font.bold: true }
}
}
}
MapCircle {
center : src.position.coordinate
radius: parent.width/10
border.width: 1
color: 'green'
}
}
PositionSource {
id: src
updateInterval: 1000
active: true
onPositionChanged: {
var coord = src.position.coordinate;
console.debug("current position:", coord.latitude, coord.longitude);
map.center = position.coordinate
}
}
}
}
Screenshot:
Upvotes: 0
Views: 2107
Reputation: 348
A MapCircle's radius is defined in meters, it is a geographical feature. You found the right solution: use a MapQuickItem. This will keep its size in, pixels 'or screen points).
Upvotes: 0
Reputation: 525
I found a solution from Qt's example called Places:
MapQuickItem {
id: yeahh
sourceItem: Rectangle { width: 10; height: 10; color: "red"; border.width: 2; border.color: "blue"; smooth: true; radius: 15 }
coordinate :src.position.coordinate
opacity:1.0
anchorPoint: Qt.point(sourceItem.width/2, sourceItem.height/2)
}
Upvotes: 2