1

我有来自 gmaps4rails 的以下代码,它不断使地图在移动浏览器中闪烁。Gmaps.map.geolocationSuccess我想知道回调触发的频率。地图在移动浏览器中闪烁是因为它真的经常刷新这个回调吗?

- content_for :scripts do
  :javascript
    Gmaps.map.geolocationSuccess = function(){
      var lng = Gmaps.map.userLocation.lng();
      var lat = Gmaps.map.userLocation.lat();
      //load map then add the markers
      $('.map_container').hide();
      $('.map_container').show();
      Gmaps.loadMaps();

      //add markers from controller
      Gmaps.map.addMarkers(#{@maps_json});

      var user_image = "http://wiki.alumni.net/wiki/images/thumb/5/55/Wikimap-blue-dot.png/50px-Wikimap-blue-dot.png";

      //add current location marker
      Gmaps.map.addMarkers([{
        "lng": lng,
        "lat": lat,
        "width":"40",
        "height":"48",
        "picture": user_image
      }]);

      //center the screen on your current location
      Gmaps.map.serviceObject.setCenter(new google.maps.LatLng(lat, lng));
      Gmaps.map.serviceObject.setZoom(14);
    };
4

0 回答 0