【发布时间】:2018-01-04 20:33:31
【问题描述】:
在 QML 地图上,使用“onCenterChanged”捕获用户激活的移动,要显示的点的过滤过程在移动启动后立即开始。
鉴于在此操作期间要处理大量数据,我希望它仅在地图完全稳定后开始(停止滑动/缩放,释放鼠标左键和鼠标滚轮不活动)。
这是 QML Map 的 sn-p
Map {
id: mainMap
anchors.centerIn: parent;
anchors.fill: parent
plugin: Plugin {name: "osm"}
center: startingPoint
zoomLevel: 4.5
onCenterChanged: {
updateBoundingBox()
}
MapItemView {
id:viewPointOnMap
model: navaidsFilter
delegate: Marker{}
}
onMapReadyChanged: {
updateBoundingBox()
}
function updateBoundingBox(){
navaidsFilter.bBox = mainMap.visibleRegion.boundingGeoRectangle() //boundingBox
}
}//Map
和过滤器 sn-ps :
void NavaidsFilter::setBBox(const QGeoRectangle &bbox)
{
if(m_processedZone.isEmpty()|| !m_processedZone.contains(bbox)){ //First bbox or displacement/zoom out of the previous box
m_processedZone = bbox;
m_boundaryZone = bbox;
invalidateFilter();
}
}
bool NavaidsFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
if(!m_boundaryZone.isValid()){
return false;
}
QModelIndex ix = sourceModel()->index(sourceRow, 0, sourceParent);
QGeoCoordinate pos = ix.data(NavaidsModel::PositionRole).value<QGeoCoordinate>();
return m_boundaryZone.contains(pos);
}
我们怎样才能做到这一点?
感谢您的帮助
【问题讨论】: