jQuery必应地图JSON重载

10

我希望使用必应地图实现以下内容。在#content中,将从JSON显示标记。

15秒后,所有标记应该被删除并重新加载。

地图和标记的加载都很好。也能够删除标记。

只有当没有新标记下载时才起作用!在控制台中,我没有收到错误消息。

有人有什么想法吗?我怀疑当“下载”发生错误时会出现问题?

代码:

function bings_maps(){
  $('#content').gmap({ 
             center: new Microsoft.Maps.Location(47.631296,15.830868),
             mapTypeId: Microsoft.Maps.MapTypeId.aerial,
             zoom: 17,
             credentials: 'test', 
             bounds: null,
             showMapTypeSelector: false,
             enableSearchLogo: false, 
             showBreadcrumb: false, 
             enableClickableLogo: false, 
             showScalebar: false, 
                           enableSearchLogo: false,
                           showDashboard: false,
                           showMapTypeSelector:false,
                           showScalebar: false,
                           useInertia: false,
                           disablePanning: false,
                           disableZooming: false,
             callback: function() {
  var self = this;
  $.getJSON('inhalt.php', function(data) {
      $.each( data.markers, function(i, marker) {
        var location = new Microsoft.Maps.Location(marker.latitude,
                                                   marker.longitude);
        self.addMarker({ 'location': location, 'bounds': false ,
                  'icon': marker.icon  } );
      });
    });
  }});
}

function bings_maps_refresh() {
  $('#content').gmap('clear', 'markers');
  $('#content').gmap({'callback':function() {
        this.addMarker({'location': '47.631296,15.830868', 'bounds': true});
}});

1
你的 JSON 响应是否通过 success 函数?也许你应该先添加一个错误函数并弹出消息,针对这个函数使用 $.getJson。 - radu florescu
1个回答

1
我怀疑你的响应数据中没有任何标记,尝试使用fiddler检查数据。或者查看Chrome开发工具(F12)中的网络区域。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接