Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javascript在jsp网站的地图上显示位置_Javascript_Jsp - Fatal编程技术网

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

使用javascript在jsp网站的地图上显示位置,javascript,jsp,Javascript,Jsp,我想从用户那里接受纬度和经度,并使用javascript显示它。我正在使用这个代码 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <

我想从用户那里接受纬度和经度,并使用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>

定位地图
函数初始化(){
变量映射选项={
缩放:8,
中心:新google.maps.LatLng(-34.397150.644),
mapTypeId:google.maps.mapTypeId.ROADMAP
};
var map=new google.maps.map(document.getElementById('map-canvas'),
地图选项);
}
google.maps.event.addDomListener(窗口“加载”,初始化);

页面已加载,但未显示任何内容。它需要javascript插件吗。我在谷歌上搜索过,但只得到了开发JavaScript项目的IDE。如果我想使用现有的IDE(ecllipse Juno),该怎么办?

您缺少CSS。加:

<style>
    html, body, #map-canvas {
        margin: 0;
        padding: 0;
        height: 100%;
    }
</style>

html,正文,#地图画布{
保证金:0;
填充:0;
身高:100%;
}

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

如何使用。我没有任何cssUm的isea,它直接来自于您从中获取原始代码的Google示例,您只是错过了CSS。查看页面的来源:谢谢,它成功了。我接受你的回答。它是否创建了画布?我不这么认为-检查元素以找出答案