gpt4 book ai didi

java - 如何使用dojo 1.9显示地理 map

转载 作者:行者123 更新时间:2023-12-01 13:56:40 25 4
gpt4 key购买 nike

我有一个特定的要求,我必须使用 dojo 1.9 绘制简单的地理 map 。我从 openlayer 网站下载了 openlayer.js,但当我运行该页面时,仍然没有显示任何内容。如果有人能帮助我解决我最后缺少的东西,我将不胜感激。请找到下面的代码。

<html>
<head>
<link rel="stylesheet" type="text/css" href="../../dijit/themes/dijit.css">
<link rel="stylesheet" type="text/css" href="../../dijit/themes/tundra/tundra.css">
<link rel="stylesheet" type="text/css" href="demo.css">
<title>Map</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="../../dijit/themes/tundra/OpenLayers.js"></script>
<script type="text/javascript" src="../../dojo/dojo.js" data-dojo-config="async: true"></script>
<script type="text/javascript" src="src.js"></script>
</head>
</html>

最佳答案

Dojo 容器内的 OpenLayers map :

<!DOCTYPE html>
<html>
<head>
<link href='//ajax.googleapis.com/ajax/libs/dojo/1.9.1/dijit/themes/claro/claro.css' rel='stylesheet' type='text/css' />
<script src='//ajax.googleapis.com/ajax/libs/dojo/1.9.1/dojo/dojo.js'></script>
<script src='//cdnjs.cloudflare.com/ajax/libs/openlayers/2.12/OpenLayers.js'></script>
<style type='text/css'>
html,body,#border,#map { margin:0; width:100%; height:100%; }
</style>
</head>
<body class='claro'>
<div id='border' data-dojo-type='dijit/layout/BorderContainer'>
<div data-dojo-type='dijit/layout/ContentPane' data-dojo-props='region:"center"'>
<div id='map'></div>
</div>
<div data-dojo-type='dijit/layout/ContentPane' data-dojo-props='region:"trailing"'>
Just an example
</div>
</div>
<script type='text/javascript'>
require(['dojo/ready', 'dojo/parser'], function (ready, Parser) {
ready(function () {
Parser.parse().then(function () {
var map = new OpenLayers.Map({
div:'map',
displayProjection:new OpenLayers.Projection('EPSG:4326'),
projection:new OpenLayers.Projection('EPSG:900913')
});
map.addLayer(
new OpenLayers.Layer.OSM()
);
map.setCenter(
new OpenLayers.LonLat(0, 0),
2
);
});
});
});
</script>
</body>
</html>

100% 的宽度和高度会扩展所有内容以填充视口(viewport)。虽然您不需要扩展到 100%,但您确实需要设置这些元素的尺寸。

关于java - 如何使用dojo 1.9显示地理 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19587074/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com