2012-11-21 90 views
0

我不明白爲什麼樣式矢量圖層是不可見的?它似乎沒有功能,但爲什麼?這段代碼有錯誤嗎? OSM,Google Layers是可見的,我可以在LayerSwitcher中進行切換(Overlay「Vectorlayer」也存在)。圖標的URL是正確的。OpenLayers矢量功能/圖層不可見(不渲染)

<html> 
    <head> 
     <meta charset="utf-8" /> 
     <title>Index</title> 
     <link href="/Content/jquery-ui.css" rel="stylesheet" type="text/css" /> 
     <script src="/Scripts/jquery-1.6.2.min.js" type="text/javascript"></script> 
     <script src="/Scripts/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script> 
     <script src="http://maps.google.com/maps/api/js?v=3&sensor=false" type="text/javascript"></script> 
     <script src="/Scripts/OpenLayers.js" type="text/javascript"></script> 


    <script type="text/javascript"> 
function Startit() { 
    var dislon = 30.4958316666667; 
    var dislat = 59.9168383333333; 
    var lonlat = new OpenLayers.LonLat(dislon, dislat); 
    var map = new OpenLayers.Map({div: "mapcontent",projection: new OpenLayers.Projection("EPSG:900913")}); 
    var maposm = new OpenLayers.Layer.OSM("OSM"); 
    var gmap = new OpenLayers.Layer.Google("Google", { numZoomLevels: 20 }); 
    var ghyb = new OpenLayers.Layer.Google("Google Earth", { type: google.maps.MapTypeId.HYBRID, numZoomLevels: 20 }); 
    map.addLayers([maposm, gmap, ghyb]); 
    lonlat.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); 
    map.setCenter(lonlat, 11); 
    var lSwitch = new OpenLayers.Control.LayerSwitcher(); 
    map.addControl(lSwitch); 
    var sdLayer = new OpenLayers.Layer.Vector("VectorLayer"); 
    var cStyle = { externalGraphic: "/images/icons/blue.png", graphicWidth: 35, graphicHeight: 35 }; 
    var currPoint = OpenLayers.Geometry.Point(dislon,dislat); 
    var ft = new OpenLayers.Feature.Vector(currPoint, null, cStyle); 
    map.addLayer(sdLayer); 
    sdLayer.addFeatures([ft]); 
} 
    </script> 

    </head> 
    <body onload="Startit();"> 
     <div id="mapcontent" style="width:500px;height:400px;"></div> 
</body> 
</html> 

回答

1

=)Omg!這只是愚蠢的錯誤>>> var currPoint = new OpenLayers.Geometry.Point(dislon,dislat);

相關問題