标题:关于qt quick开发地图程序的zoomout,zoomin
作者:yangzl
日期:2011-11-03 11:14
内容:
我使用qt quick的方式开发地图程序,在地图上用mapimage显示了一个图标,但是这个图标在地图放大缩小的时候屏幕位置不变,但是拖动地图时图标也跟着移动而且位置是正确的,这是怎么回事。在放大和缩小的时候我怎么控制这个图标的位置呢?
import QtQuick 1.1
import QtMobility.location 1.2
Item {
id: page
anchors.fill: parent
focus: true
property int selectedIcon: -1; // selected icon
property int xwitdh: 26; // icon width
property int xhight: 26; // icon hight
property int zoom_tmp;
TitleBar { id: titleBar; appname: "Map Markers"; z: 5; width: parent.width; height: 40; opacity: 0.8 }
function selectMarkerIcon(mx, my){
{
var topLeftPoint = map.toScreenPosition(maker.coordinate);
var xStart = parseInt(topLeftPoint.x);
var yStart = parseInt(topLeftPoint.y);
if((mx >= xStart) && (my >= yStart)
&& (mx = 0){
maker.source = "images/button-green.png";
}
selectedIcon = -1;
__isPanning = false
}
onPositionChanged: {
if(selectedIcon >= 0 ){
maker.coordinate = map.toCoordinate(Qt.point((mouse.x - (xwitdh / 2)),(mouse.y - (xhight / 2))));
} ..
#1 [yangzl 11-03 11:25]
如果我把maker移动个位置再zoomin zoomout,它改变的位置不正确。
#2 [yangzl 11-03 15:13]
发现问题了,是我没有设置offset.x和offset.y