Русскоязычный портал о QML и QtQuick, QmlPortal What the duck
[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]
  • Страница 1 из 1
  • 1
Форум QML » QML форум » Вопросы по QML » Xml and MapCircle
Xml and MapCircle
AaronДата: Суббота, 18.05.2013, 02:16 | Сообщение # 1
Рядовой
Группа: Пользователи
Сообщений: 1
Награды: 0
Репутация: 0
Статус: Offline
Здравствуйте! Ситуация такая, есть приложение, которое загружает карту. Там добавлены всякие кнопки типа увеличить, уменьшить, выйти в главное меню и самое главное - перейти к предыдущей точке на карте, показать информацию по текущей и перейти к следующей. Считываю данные я из xml, далее работаю с xmllistmodel, listview и т.п. В общем я сделал так, чтобы менялась информация о точке на карте при переходе от одной точки к другой, а вот, чтобы изменялось положение самой этой точки, как-то не вышло. Помогите пожалуйста решить эту проблему

Rectangle{id:uiwidth:parent.widthheight:parent.heightvisible:falsefocus:trueMap{id:mapz:1plugin:Plugin{name:"nokia"}
size.width:parent.widthsize.height:parent.heightzoomLevel:15mapType:Map.StreetMapcenter:Coordinate{latitude:57.678longitude:39.8}
Rectangle{x:ui.width-1.4*plus_button.widthy:0.4*plus_button.heightButton{id:plus_buttonz:1width:50height:50text:"+"onClicked:map.zoomLevel+= 1}
Button{id:minus_buttonanchors.top:plus_button.bottomz:1width:50height:50text:"-"onClicked:map.zoomLevel-=1}
}
Rectangle{x:0.4*plus_button.widthy:0.4*plus_button.heightButton{id:cancel_buttonz:1width:50height:50text:"X"onClicked:{menu.state="hide"}}
}

MapCircle{id:circlecenter:Coordinate{latitude:57.678longitude:39.8}
color:"#80FF0000"radius:map.size.width/map.zoomLevel/3}

MapMouseArea{propertyintlastX:-1propertyintlastY:-1onPressed:{lastX=mouse.xlastY=mouse.y}
onReleased:{lastX=-1lastY=-1}
onPositionChanged:{if(mouse.button==Qt.LeftButton){if((lastX!=-1)&&(lastY!=-1)){vardx=mouse.x-lastXvardy=mouse.y-lastYmap.pan(-dx,-dy)}
lastX=mouse.xlastY=mouse.y}
}
onDoubleClicked:{map.center=mouse.coordinatemap.zoomLevel+=1lastX=-1lastY=-1}
}
}

XmlListModel{id:excursModelsource:"C:/Users/Leon/Documents/QtProjects/Map_Example/qml/Map_Example/excursion.xml"query:"/DOCUMENT/EXCURSION"XmlRole{name:"name";query:"name/string()"}XmlRole{name:"info";query:"info/string()"}}

ListView{id:attrinfowidth:frame.width/2height:frame.height/2.4x:ui.width/36z:0anchors.centerIn:frame.Centermodel:xmlModelanchors.bottom:parent.bottomclip:falseinteractive:falsedelegate:ViewWindow{title:name;text:info;}orientation:ListView.Horizontalspacing:10}

PinchArea{id:pinchareapropertydoubleoldZoomanchors.fill:parentfunctioncalcZoomDelta(zoom,percent){returnzoom+Math.log(percent)/Math.log(2)}
onPinchStarted:{oldZoom=map.zoomLevel}
onPinchUpdated:{map.zoomLevel=calcZoomDelta(oldZoom,pinch.scale)}
onPinchFinished:{map.zoomLevel=calcZoomDelta(oldZoom,pinch.scale)}
}

MyButton{id:prev_buttonx:0y:parent.height-48z:1width:parent.width/3-1height:50text:"Prev"color:"gray"radius:5MouseArea{anchors.fill:parentonClicked:if(attrinfo.currentIndex>0)attrinfo.currentIndex--;}
}
MyButton{id:play_buttonx:parent.width/3y:parent.height-48z:1width:parent.width/3-2height:50text:"Play"color:"gray"radius:5MouseArea{anchors.fill:parentonClicked:if(attrinfo.z==1)attrinfo.z=0elseattrinfo.z=1}
}
MyButton{id:next_buttonx:2*parent.width/3y:parent.height-48z:1width:parent.width/3-1height:50text:"Next"color:"gray"radius:5MouseArea{anchors.fill:parentonClicked:if(attrinfo.currentIndex<attrinfo.count-1)attrinfo.current Index++;}
}

Keys.onPressed:{switch(event.key){
caseQt.Key_VolumeUp:caseQt.Key_Plus:map.zoomLevel+=1;break;caseQt.Key_VolumeDown:caseQt.Key_Minus:map.zoomLevel-=1;break;caseQt.Key_T:if(map.mapType==Map.StreetMap){map.mapType=Map.SatelliteMapDay}elseif(map.mapType==Map.SatelliteMapDay){map.mapType=Map.StreetM ap}
break;}
}
}
 
Форум QML » QML форум » Вопросы по QML » Xml and MapCircle
  • Страница 1 из 1
  • 1
Поиск: