<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<script src="http://openlayers.org/api/2.10/OpenLayers.js" type="text/javascript">
var map, layer;
function init(){
map = new OpenLayers.Map('map', {controls: [
new OpenLayers.Control.Navigation({documentDrag: true}),
new OpenLayers.Control.PanZoom(),
new OpenLayers.Control.ArgParser(),
new OpenLayers.Control.Attribution()
]});
layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0",
{layers: 'basic'});
map.addLayer(layer);
map.zoomToMaxExtent();
}
</script>
</head>
<body onload="init()">
<h1 id="title">OpenLayers Document Drag Example</h1>
<div id="tags">
drag
</div>
<div id="shortdesc">Keep on dragging even when the mouse cursor moves outside of the map</div>
<div id="map" class="smallmap"></div>
<div id="docs">
<p>This example shows how to make a map draggable outside of the map itself.</p>
</div>
</body>
</html>
這是我用javascript編寫的html代碼。我的螢火蟲拋出未定義的錯誤init()。什麼可能是錯誤?init錯誤()未定義。如何消除這個錯誤?
謝謝。雖然錯誤消失了,但仍然沒有顯示OpenLayers地圖的跡象。 – IamH1kc
我對打開圖層不熟悉,但是不應將「map」參數作爲傳遞給Map()的對象的一部分?像「Map({div:」map「,controls:...});'? –