简体   繁体   English

在另一个jsp页面上的div上加载一个包含Gmap的jsp页面

[英]loading a jsp page contains Gmap , on div in another jsp page

I am trying to load a jsp page which consist google map , inside another jsp page div but its not showing map on that div. 我正在尝试在另一个jsp页面div中加载包含google map的jsp页面,但是在该div上未显示地图。 Other two jsp pages processed , unprocessed coming on divs fine. 另外两个已处理的jsp页面,未处理的divs很好。

// JSP hello.jsp // JSP hello.jsp

<script>
$(function() {
$( "#tabs" ).tabs();
$("#map_canvas").load("map.jsp");
$("#tabs-1").load("Processed.jsp");
$("#tabs-2").load("UnProcessed.jsp");
});
</script>

<div id="tabs">
<ul>
<li> <a href="#map_canvas">GMaps</a></li>
    <li> <a href="#tabs-1">Processed </a></li>
    <li> <a href="#tabs-2">UnProcessed </a></li>
</ul>
<div id ="map_canvas"></div>
<div id="tabs-1"></div>
<div id="tabs-2"></div>
</div></body></html>

// map.jsp // map.jsp

<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
  #map-canvas {
    margin: 0;
    padding: 0;
    width: 600px;
    height: 300px;
  }
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
var map;
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
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>

// I had already spent too much time on this but still not getting result , map is not   loading on page , please help me to load map.jsp on`map_canvas` div in hello.jsp . Thanks A tonn...

dude, i got your issue, 老兄,我知道你的问题,

In map.jsp, use may be using some style like 在map.jsp中,使用可能使用了某些样式,例如

#map-canvas {
        width: 500px;
        height: 400px;
      }

remove and paste this css in the hello.jsp code and try pasting the javascript code in hello.jsp page, ie initialize and loadScript function rest every thing works nice, have tested locally here, should work for you also 删除此css并将其粘贴到hello.jsp代码中,然后尝试将javascript代码粘贴到hello.jsp页面中,即,initialize和loadScript函数使所有事情都工作正常,在这里进行了本地测试,也应该对您有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM