通过webapp调用参数? [英] Call parameter through a webapp?

查看:28
本文介绍了通过webapp调用参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码获取 2 个不同地址之间的距离,并以英里、公里或分钟为单位返回距离.我的理解是我可以使用 google.script.run.googleMaps();

The code below gets the distance between 2 different addresses and returns the distance in miles, kilometers or minutes. My understanding was that I could execute my app-script in a web app using google.script.run.googleMaps();

我的问题是如何使用输入字段作为我的来源和两列在网络应用程序中复制相同的结果?

My question is how do I use input fields as my from and two columns to replicate the same result in a web app?

function googleMaps(start_address,end_address, return_type){

   var mapObj = Maps.newDirectionFinder();
   mapObj.setOrigin(start_address);
   mapObj.setDestination(end_address);
   var directions = mapObj.getDirections();

   var getTheLeg = directions["routes"][0]["legs"][0];

   var meters = getTheLeg["distance"]["value"];

  switch(return_type){
    case "miles" :
      return Math.floor(meters * 0.000621371);
      break;
    case "kilometers" :
      return meters / 1000;
      break;
    case "minutes" :
      var duration = getTheLeg["duration"]["value"];
      return duration / 60;
      break;
    default :
      return "Error: Wrong unit type";
  }
}

推荐答案

可以直接传递:google.script.run.googleMaps(start_address,end_address, return_type);

这篇关于通过webapp调用参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆