1
我认为这与我有限的JavaScript经验有关。 我使用由谷歌Node.js的客户端库,在这里找到 - https://github.com/googlemaps/google-maps-services-js 的例子展示了如何创建一个客户对象使用node.js谷歌地图客户端库
var googleMapsClient = require('@google/maps').createClient({
key: 'your API key here'
});
再怎么跑gecode请求,并打印出结果:
// Geocode an address.
googleMapsClient.geocode({
address: '1600 Amphitheatre Parkway, Mountain View, CA'
}, function(err, response) {
if (!err) {
console.log(response.json.results);
}
});
我需要做的是从文件中读取地址列表并为所有地址构建一个对象数组。
我希望我的代码做线沿线的东西:
create address-objects array
create a client object
open the text files
for each line in text files
geocode the line(address)
add the address and the results into an object and add it to the address-objects
我不明白googleMapsClient.geocode是否返回的东西,如果是我该如何访问呢?我应该把它设置成线沿线的一些变量:
var gc_results = googleMapsClient.geocode(param , ...)
希望我是清楚的,在此先感谢 乔纳森。