小编Sho*_*use的帖子

我可以减少 Google Maps JavaScript API v3 中的请求量吗?

我给 2 个地点打电话。我从 xml 文件中获取某个位置的经度和经度。首先是最近的咖啡馆,然后是最近的学校。

$.get('https://maps.googleapis.com/maps/api/place/nearbysearch/xml?
location='+home_latitude+','+home_longtitude+'&rankby=distance&types=cafe&sensor=false&key=X',function(xml)
{
verander($(xml).find("result:first").find("geometry:first").find("location:first").find("lat").text(),$(xml).find("result:first").find("geometry:first").find("location:first").find("lng").text());
}
);

$.get('https://maps.googleapis.com/maps/api/place/nearbysearch/xml?
location='+home_latitude+','+home_longtitude+'&rankby=distance&types=school&sensor=false&key=X',function(xml)
{
verander($(xml).find("result:first").find("geometry:first").find("location:first").find("lat").text(),$(xml).find("result:first").find("geometry:first").find("location:first").find("lng").text());
}
);
Run Code Online (Sandbox Code Playgroud)

但正如您所看到的,我执行了函数 verander(latitude,longitude) 两次。

function verander(google_lat, google_lng)
  {
        var bryantPark = new google.maps.LatLng(google_lat, google_lng);
        var panoramaOptions = 
        {
            position:bryantPark,
            pov:
            {
                heading: 185,
                pitch:0,
                zoom:1,
            },
            panControl : false,
            streetViewControl : false,
            mapTypeControl: false,
            overviewMapControl: false   ,
            linksControl: false,
            addressControl:false,
            zoomControl : false,
        }
        map = new google.maps.StreetViewPanorama(document.getElementById("map_canvas"), panoramaOptions);
        map.setVisible(true);
  }
Run Code Online (Sandbox Code Playgroud)

是否可以仅在一个请求中推送这两个位置(也许通过数组)?我知道这听起来很愚蠢,但我真的想知道它们是否不是减少这些谷歌地图请求的后门。

FTR:这是对 Google 的请求:

在适用于 Maps API 的使用限制的背景下,什么构成“地图加载”?在以下情况下会发生单个地图加载:

  • A。当网页或应用程序加载时,使用 Maps JavaScript API(V2 或 …

performance google-maps request google-maps-api-3

2
推荐指数
1
解决办法
5480
查看次数

使用其他按钮 Javascript 触发 fb:login-button

我想触发fb:login-button

<fb:login-button show-faces="true" width="200" max-rows="1"></fb:login-button>
Run Code Online (Sandbox Code Playgroud)

带有第二个按钮。为什么?我无法调整 Facebook 的 css,我想要一个带有自定义图像的精美按钮来替换它。我的大问题是我不知道 FB 按钮的 ID 是什么,而且我不能给它一个。

我的错误代码:

<script>
    function Ffirst()
    {
    alert("first");
    $("fb:login-button").click(); 
    //$("fb:login-button").trigger("click"); //doesn't work eiter
    }
</script>

<input type="submit" onclick="Ffirst()" name="savebutton" id="first" />
<fb:login-button show-faces="true" width="200" max-rows="1"></fb:login-button>
Run Code Online (Sandbox Code Playgroud)

FTR: 这就是我按下时发生的情况the fb:login-button

FB.Event.subscribe('auth.authResponseChange', function(response) {
    // Here we specify what we do with the response anytime this event occurs. 
    if (response.status === 'connected') {
          testAPI();
    }

    } else if (response.status === 'not_authorized') {
      FB.login();

    } else {
          FB.login();
    }
  }); …
Run Code Online (Sandbox Code Playgroud)

facebook button facebook-javascript-sdk facebook-login

2
推荐指数
1
解决办法
4528
查看次数