拾取坐标功能

功能描述: 拾取坐标
用户点击vue中的Button后,

Alice John Bob Hello John, how are you? 1 Fight against hypochondria 2 loop [Healthcheck] Rational thoughts! Great! 3 How about you? 4 Jolly good! 5 Alice John Bob

vue ->>+ index.html: 发送消息:
index.html -->>- CoomandManager.js:
CoomandManager.js -->> index.html:
index.html -->>- vue:

vue页面

  getcoord () {  //拾取坐标的方法
                  // 1.向index.html发送消息
    let messager = window.messagerService;
    let postData = {
      event: 'jicheng:PowerdataSubmited',
      data: ''
    };
    messager.postMessageToParent(postData);
  }
  // 监听来自父级页面的消息
  addMessageListener: function () {
    let messager = window.messagerService;
    messager.addListener('jicheng:PowerdataSubmited', (data) => {
      console.log('event data from parent page', data);
      topic.publish(Messages.MISPANE_OPEN);
      if (data) {
      }
    });
  },

index.html页面

var xytolonlat = webMercatorUtils.xyToLngLat;
// console.log("webMercatorUtils", webMercatorUtils)

window.messagerService.addListener('jicheng:PowerdataSubmited', function(data) {
	var listener = topic.subscribe(Messages.EDITOR_DRAWPOINT_END, function(param) {
		// console.log(webMercatorUtils)
		var graphic = param.drawgraphic;
		var point = param.drawgraphic.geometry;
		var p = xytolonlat(point.x, point.y);
		point = new Point(p[0], p[1]);
		window.messagerService.postMessageToChildIframe({
			event: 'jicheng:PowerdataSubmited',
			data: JSON.stringify(point)
		})
		listener.remove();  //dojo topic subscribe 取消监听
	});
	console.log("listener", listener)
	topic.publish(Messages.MISPANE_CLOSE);
	topic.publish(Messages.EDITOR_DRAWPOINT, {
	"token": "pickupnewclear"
	});
});

dojo发布者订阅者模式(topic.publish/topic.subscribe)

CommandManager.js

//拾取坐标
topic.subscribe(Messages.EDITOR_DRAWPOINT_END, dojo.hitch(this,function(param){
	if(param.token=="pickupnewclear"){
		topic.publish(Messages.NUCLEAR_EDIT_SET_LOCATION, param);
	}
}));
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值