前提

3.2所插入代码段中的ak需要前去 http://api.map.baidu.com/lbsapi/控制台进行获取和根据项目情况进行相关设置

 

根据地址获取坐标

1.创建XXX.json
2.将输入的地址或选择的地址拼接为"北京市北京市海淀区蓝靛厂"的格式并传入所创建的json,字段为"dizhi"

3.编辑XXX.json

3.1 输入参数

 

3.2插入下方代码段:

/*INSBEGIN:RESTAPI*/
          //@wwcomments:通过百度api将地址转成坐标
          function() {
            var requestlib = require("request");
            var urllib = require("url");
            var url = "http://api.map.baidu.com/geocoding/v3/?output=json&ak=N6pjAxohY1KrGQ4hKtB6wMyHwNkB7FRs&address=" + encodeURIComponent(inputs.dizhi);
            var urlObj = urllib.parse(url);
            var option = {
              "url": urlObj,
              "method": "GET"
            };
            option.headers = {};
            return when.promise(function(resolve, reject, notify) {
              requestlib(option, function(e, r, b) {
                if (e) {
                  reject(e);
                }
                resolve(b);
              });
            });
          },
          //
          //@wweditorinfo:{"id":"5426511f4d83cc3e09ef48e0d5f579d2","editor":{"step1":{"url":{"from":"const","value":"http://api.map.baidu.com//geocoder/v2/?output=json&ak=qlZzbMADpf5wc7NQqpDuGAHWqwSPmY7h&address=%E5%8C%97%E4%BA%AC%E5%B8%82"},"method":"GET","multiUrl":false},"step2":{"bodytype":"application/x-www-form-urlencoded","auth":{"empty":""},"parameters":[],"signature":"no"},"step3":{"xml2json":false,"selfcert":false,"headers":[],"customeHeaders":[]}}}
          /*INSEND:RESTAPI*/

 

3.2添加变量采集器:

3.3 插入自定义代码段: