- Plugin, 指定地图的类型
Plugin {
id: myPlugin
name: \"osm\"// 指定为open street map 地图
}
- map,显示地图,缩小和放大地图,改变位置
Map {
id: map
width: parent.width
anchors.top: searchRow.bottom
anchors.bottom: parent.bottom
plugin: myPlugin
center: locationBeijing
zoomLevel: 15
minimumZoomLevel: 2
gesture.enabled: true
activeMapType: supportedMapTypes[1]
onCenterChanged: {
//console.log(\"center changed : \" + center.longitude + \" \" + center.latitude)
coordinateText.text = \"(\" + center.latitude.toFixed(4) +\", \" + center.longitude.toFixed(4) + \")\"
}
}
- PositionSource,获取位置的组件,可以设置获取位置的时间间隔
PositionSource {
id: positionSource
property variant lastSearchPosition: locationBeijing
active: true
updateInterval: 1000*10
onPositi d: {
changePosition()
}
}
- 获取当前位置并 显示当前地图
positionSource获取当前位置,然后把坐标值赋值给map的center,地图就会显示当前位置。
同理,把map的center赋值成任何一个坐标,地图变化到改坐标点。
function changePosition()
{
var currentPosition = positionSource.position.coordinate
console.log(\"GPS update currentPosition = \", currentPosition.longitude,
currentPosition.latitude)
map.center = currentPosition
}
继续阅读与本文标签相同的文章
上一篇 :
如何搭建自己的深度学习工作站?
下一篇 :
正确认识网站设计小H,这个标签有大用处!
-
8 分钟了解 Kubernetes
2026-05-18栏目: 教程
-
Helm 从入门到实践 | 从 0 开始制作一个 Helm Charts
2026-05-18栏目: 教程
-
阿里云突发性能实例t5 和共享型实例xn4 n4的区别
2026-05-18栏目: 教程
-
【DockerCon2017技术解读】Docker特性介绍
2026-05-18栏目: 教程
-
面向海量数据的极致成本优化-云HBase的一体化冷热分离
2026-05-18栏目: 教程
