0

如果我删除 ", zoomLevel: 10" 部分,那么我可以看到 "Hello World" div。如果我重新添加它,那么 mapContainer div 会占据整个页面,因此我看不到“Hello World”div。你能指出我应该如何编码我的 html/css/javascript 以控制地图元素接管多少页面的示例吗?

<div>Hello World</div>
<div id="mapContainer"></div>
~
~
~
var map = new nokia.maps.map.Display(mapContainer, {
    center: [52.51, 13.4], zoomLevel: 10 

});
4

1 回答 1

2

两者的某种组合:

  • 具有绝对位置的百分比,例如width:100%; height:90%; left: 0; top: 1em; position: absolute;
  • 高度上的固定像素大小,例如width:600px; height:600px;

换句话说,像这样:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="X-UA-Compatible" content="IE=7; IE=EmulateIE9" />



<title>Map with a DIV</title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

<script language="javascript"  src="http://api.maps.nokia.com/2.2.4/jsl.js" type="text/javascript" charset="utf-8"></script>

</head>
<body>
<div> I'm a DIV</div>
<div id="mapcanvas"  style="width:100%; height:600px;" >&nbsp;</div><br/><br/>  


<script type="text/javascript">
// <![CDATA[    

/////////////////////////////////////////////////////////////////////////////////////
// Don't forget to set your API credentials
//
// Replace with your appId and token which you can obtain when you 
// register on http://api.developer.nokia.com/ 
//
            nokia.Settings.set( "appId", "YOUR APP ID GOES HERE"); 
            nokia.Settings.set( "authenticationToken", "YOUR AUTHENTICATION TOKEN GOES HERE");

/////////////////////////////////////////////////////////////////////////////////////   


 map = new nokia.maps.map.Display(document.getElementById('mapcanvas'), {
     'components': [ 
        // Behavior collection
        new nokia.maps.map.component.Behavior(), 
        new nokia.maps.map.component.ZoomBar()
        ],
    'zoomLevel': 5, // Zoom level for the map
    'center': [41.0125,28.975833] // Center coordinates
});
// ]]>
</script>
</body>
</html>
于 2013-06-06T15:25:49.443 回答