它現在是固定的,我猜Twitter的Bootstrap CSS必須與高度和寬度設置爲100%相沖突。留下任何有類似問題的人。谷歌地圖API不顯示地圖上的頁面不確定爲什麼
我想實現我的網頁上的谷歌地圖,當用戶點擊一個鏈接,所有的PHP工作正常,但由於某些原因,谷歌地圖沒有顯示,我重新閱讀API的所有實例文檔和重新讀取所有的代碼,但仍然沒有工作不知道爲什麼..
這裏是顯示在地圖
注意頁面:PHP的正常工作和腳本被在頁面加載加載,但地圖不是。
<?php
/* Include header and config and set variable*/
require_once('config.inc.php');
require_once($rootdir . $dirsubfolder . 'navbar.php');
$route = $_GET['route'];
?>
<?php
/* User wants to retrieve their route */
if (isset($route)) {
?>
<?php
/* User wants Route 1 */
if (strcmp($route, "sunroute1") == 0) {
?>
<script type="text/javascript">
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
}
function loadScript() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://maps.googleapis.com/maps/api/js?key=WORKINGKEYk&sensor=true&callback=initialize";
document.body.appendChild(script);
}
window.onload = loadScript;
</script>
<?php
printf('worked');
} else { printf('failed'); }
?>
<div class="container">
<div class="hero-unit">
<div id="map_canvas" style="width: 100%; height: 100%"></div>
</div>
</div>
<?php
/* End isset(route) */
}
/* Include footer */
require_once($rootdir . $dirsubfolder . 'footer.php');
?>
和我的footer.php裏面我有
<script src="https://maps.googleapis.com/maps/api/js?key=MYKEYWORKING&sensor=false"></script>
下面是從頁
<script type="text/javascript">
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
}
function loadScript() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://maps.googleapis.com/maps/api/js?key=WORKING&sensor=true&callback=initialize";
document.body.appendChild(script);
}
window.onload = loadScript;
</script>
worked
<div class="container">
<div class="hero-unit">
<div id="map_canvas" style="width: 100%; height: 100%"></div>
</div>
</div>
的view source
和我的頁腳腳本
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="js/bootstrap-transition.js"></script>
<script src="js/bootstrap-alert.js"></script>
<script src="js/bootstrap-modal.js"></script>
<script src="js/bootstrap-dropdown.js"></script>
<script src="js/bootstrap-scrollspy.js"></script>
<script src="js/bootstrap-tab.js"></script>
<script src="js/bootstrap-tooltip.js"></script>
<script src="js/bootstrap-popover.js"></script>
<script src="js/bootstrap-button.js"></script>
<script src="js/bootstrap-collapse.js"></script>
<script src="js/bootstrap-carousel.js"></script>
<script src="js/bootstrap-typeahead.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=WORKING&sensor=false"></script>
</body>
</html>
你在任何地方調用你的initialize()函數嗎? – OzBarry 2013-03-03 05:08:13
@OzBarry設法解決它,CSS令人傷心地:/謝謝。 – Datsik 2013-03-03 05:08:52
啊,沒問題。 – OzBarry 2013-03-03 05:10:43