0
我使用下面給出的代碼來演示OpenLayers
地圖在DIV
容器中。我不知道爲什麼,但我必須多次重新打開網頁才能看到地圖。這不是互聯網連接速度的問題。我真的必須點擊幾個jQuery選項卡,最後地圖在指定的選項卡中打開。確實沒有錯誤信息產生。它發生在Chrome和Firefox中。我不知道這是一個錯誤還是我的錯誤。OpenLayers + Ajax:錯誤或錯誤
請高度讚賞任何建議。
mainPage.php
<script type="text/javascript">
$(document).ready(function() {
$("#tabs").tabs({
ajaxOptions: {
success: function(html) {
$("#content").html(html);;
}
}
});
});
</script>
<div id="tabs">
<ul>
<li><a href="administration.php"><span>Administration</span></a></li>
<li><a href="map.php"><span>Map</span></a></li>
</ul>
</div>
map.php
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script>
map = new OpenLayers.Map("basicMap");
map.addLayer(new OpenLayers.Layer.OSM());
var points = new OpenLayers.Layer.Text("Resource Locations",
{ location: "dataLonLat.php",
projection: map.displayProjection
});
map.addLayer(points);
var geographic = new OpenLayers.Projection("EPSG:4326");
var mercator = new OpenLayers.Projection("EPSG:900913");
//Set start centrepoint and zoom
var lonLat = new OpenLayers.LonLat(2.07632,41.30408)
.transform(
geographic, // transform from WGS 1984
mercator // to Spherical Mercator Projection
);
var zoom=16;
map.setCenter (lonLat, zoom);
</script>
<div id="basicMap" style="width: 100%; height: 100%;">
</div>