首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用javascript在jsp网站的地图上显示位置

使用javascript在jsp网站的地图上显示位置
EN

Stack Overflow用户
提问于 2013-06-07 17:14:12
回答 1查看 851关注 0票数 0

我想接受用户的纬度和经度,并使用javascript显示它。我正在使用这个代码。

代码语言: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)怎么办?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-06-07 17:22:31

你错过了CSS。添加:

代码语言:javascript
复制
<style>
    html, body, #map-canvas {
        margin: 0;
        padding: 0;
        height: 100%;
    }
</style>

根据谷歌的例子,它将会起作用。在本地测试。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16980437

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档