我想接受用户的纬度和经度,并使用javascript显示它。我正在使用这个代码。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Localizing the Map</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<link href="/maps/documentation/javascript/examples/default.css" rel="stylesheet">
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&language=ja"></script>
<script>
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>页面已加载,但未显示任何内容。它需要任何javascript插件吗。我在谷歌上搜索,但只有集成开发环境来开发JavaScript项目。如果我想使用现有的IDE(ecllipse Juno)怎么办?
发布于 2013-06-07 17:22:31
你错过了CSS。添加:
<style>
html, body, #map-canvas {
margin: 0;
padding: 0;
height: 100%;
}
</style>根据谷歌的例子,它将会起作用。在本地测试。
https://stackoverflow.com/questions/16980437
复制相似问题