GitHub:八至

作者:狐狸家的鱼

本文链接:实现QML中显示html中地图的坐标

如何QML与HTML通信已经在这篇文章 QML与HTML通信之画图 详细讲述了

1.HTML

var coord;
map.on('singleclick',(evt)=>{
       coord = ol.coordinate.toStringXY(ol.proj.transform(evt.coordinate,'EPSG:3857','EPSG:4326'),2);
       content.changeText(coord);
});

2.QML

(1)WebChannel中

function changeText(newText) {//鼠标点击经纬度显示 鼠标点击时会调用该函数 并更新文本coordinateTex
        console.log(newText);
        giwSC.coordinateTex = newText;//
    }

(2)label.qml中

MyText{
      id:coordinateTex;
      fontSize: l;
      text: "104.08,30.66";
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-28
  • 2021-11-12
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-06
  • 2021-07-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
相关资源
相似解决方案