2012-10-01 66 views
1

試圖通過地址執行搜索使用jquery-ui-map插件。jquery-ui-map:搜索無效(Google Maps API)

Firefox的報道:類型錯誤:H [B]是未定義 /js/ui-map/jquery.ui.map.full.min.js行:2

$(document).ready(function() { 
     $('#map_canvas').gmap('search', { 'address': 'Stockholm' }, function(isFound,results) { 
      if (isFound) { 
       $('#map_canvas').gmap('getMap').panTo(results[0].geometry.location); 
      } 
     }); 
}); 

請幫助。

編輯:在http://code.google.com/p/jquery-ui-map/issues/detail?id=64

+0

加入我的錯誤,以及對跟蹤器。我有與findMarker相同的問題。想知道它是不是jQuery。你的jQuery版本是什麼? – Spir

+0

我在閱讀@johansalllarsson備註後終於修復了我的問題: 'findMarker主要用於'搜索',您應該使用$('#m').gmap('get','markers')['m_1'], $('#m').gmap('get','markers').m_1或$('#m').gmap('get','markers> m_1')會更快。因此,$('#m').gmap('get','markers> m_1')。tags ='something';會比使用findMarker更好。' Here: https://groups.google.com/forum/?fromgroups=#!topic/jquery-ui-map-discuss/Dl9m7IeIxh0 – Spir

回答

2

代替GMAP( '的GetMap')應該使用GMAP( '得到', '地圖')報告給開發者。除此之外,您還交換isFound結果正確的樣本是:

$(document).ready(function() { 
     $('#map_canvas').gmap('search', { 'address': 'Stockholm' }, function(results,isFound) { 
      if (isFound) { 
       $('#map_canvas').gmap('get','map').panTo(results[0].geometry.location); 
      } 
     }); 
});