在另一个脚本中访问返回的Javascript变量

在另一个脚本中访问返回的Javascript变量,javascript,jquery,google-maps,scope,Javascript,Jquery,Google Maps,Scope,我有一个脚本(a),它是一个javascript脚本,我在其中实现了以下功能: function csf_viewport_bounds() { var bounds = map.getBounds(); var ne = bounds.getNorthEast(); var sw = bounds.getSouthWest(); var maxLat = ne.lat(); var maxLong = ne.lng(); var minLat

我有一个脚本(a),它是一个javascript脚本,我在其中实现了以下功能:

function csf_viewport_bounds() {
    var bounds = map.getBounds();
    var ne = bounds.getNorthEast();
    var sw = bounds.getSouthWest();

    var maxLat = ne.lat();
    var maxLong = ne.lng();
    var minLat = sw.lat();
    var minLong = sw.lng();

    var the_maps_bounds = [maxLat, maxLong, minLat, minLong];

    return(the_maps_bounds);
 }
我还有jQuery脚本(b)。它有一行调用(a)中的函数:

如何访问脚本(b)中由(a)返回的内容(即_映射_边界)

谢谢。

将脚本(b)更改为:


只需再次调用该函数,因为它不使用任何参数,并将结果赋给变量

var myStuff = csf_viewport_bounds()

我假设您希望在加载
tilesload
之后执行一些涉及
映射\u边界的操作,在这种情况下,您可以执行以下操作:

google.maps.event.addListener(map, 'tilesloaded',  function() {
    // This code will only execute after event `tilesloaded` happens

    var the_maps_bounds = csf_viewport_bounds()

    // now do something with the bounds
    // ...
});
var myStuff = csf_viewport_bounds()
google.maps.event.addListener(map, 'tilesloaded',  function() {
    // This code will only execute after event `tilesloaded` happens

    var the_maps_bounds = csf_viewport_bounds()

    // now do something with the bounds
    // ...
});