谷歌地图无法正确渲染

时间:2012-06-14 23:18:17

标签: google-maps backbone.js

我正在使用backbone和gmaps.js,由于某种原因,地图无法正确呈现......

控制器没有正确显示,而且infowindow也呈现出奇怪的效果。

我正在使用gmaps.js library。我甚至不知道如何调试这个东西......

这是我对地图的主干视图:

App.MapView = Backbone.View.extend({
   el: '.map',
   initialize: function() {
       this.map = new GMaps({
           div: this.el,
           lat: -12.043333,
           lng: -77.028333,   
       });
       App.houseCollection.bind('reset', this.populateMarkers, this);
   },
   populateMarkers: function(collection) {
       _.each(collection.models, function(house) {
            var html = 'hello'
            this.map.addMarker({
                lat: house.attributes.lat,
                lng: house.attributes.lng,
                infoWindow: {
                    content: html,
                }                
            });
       }, this);
   },
});

由于

enter image description here

1 个答案:

答案 0 :(得分:7)

我见过类似屏幕截图的问题,修复方法是将这些行添加到CSS中:

#map label { width: auto; display:inline; }
#map img { max-width: none; max-height: none; }

(如果需要,将#map替换为你的地图的div id或类名)与backbone或gmaps.js无关,我不认为,可能是你页面的其他组件。