【发布时间】:2023-03-16 07:49:01
【问题描述】:
我在我的网站上使用Angular.js,并且我能够使用特定地理编码上的引脚加载地图,其中包含我从服务器上的GET 请求中获取的数据。但是,当用户转到新页面时,地图会加载……但只是部分加载。地图的其余部分是灰色区域。我的代码如下:
data.map.center = new google.maps.LatLng(parseFloat(response.geocode.latitude), parseFloat(response.geocode.longitude));
data.map.mapEnabled = true;
var map_canvas = document.getElementById('map_canvas');
var map_options = {
center: data.map.center,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP,
zoomControl: false,
panControl: false,
scrollwheel: false,
draggable: false,
mapTypeControl: false,
streetViewControl: false
};
data.map.mapObject = new google.maps.Map(map_canvas, map_options);
var marker = new google.maps.Marker({
map: data.map.mapObject,
position: data.map.center
});
地图部分加载到下一页是否有原因?当我进行刷新时,它会完全加载它,但为什么它最初不起作用?
我阅读了以下内容:
Google Maps API v3: How to remove all markers?
Google Maps API V3 not rendering competely on tabbed page using Twitter's Bootstrap
编辑
似乎部分原因是当用户单击第二个链接时我没有刷新页面。我只使用哈希然后以这种方式加载它......不确定我是否应该为此做些不同的事情?
【问题讨论】:
标签: angularjs google-maps