我使用具有地图的加载方法显示页面。问题是页面已加载,但在地图 div 中显示灰色屏幕。当我刷新页面时,地图被加载。我也在文档就绪函数中调用地图函数。但没有用。
我的代码是
<div class="public-view" id="map_canvass">
<script type="text/javascript">
// OnLoad function ...
initialize();
function initialize() {
var fenway = new google.maps.LatLng(<?php echo $propertyValues->lat; ?>, <?php echo $propertyValues->lng; ?>);
var mapOptions = {
center: fenway,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvass"), mapOptions);
var circleOptions = {
center: fenway,
map: map,
strokeColor: "#BB0A68",
strokeOpacity: 0.1,
fillColor: "#BB0A68",
fillOpacity: 0.35,
radius: 200
}
var circle = new google.maps.Circle(circleOptions);
google.maps.event.trigger(map, 'resize');
}
</script>
</div>