地图花边地图没有显示出来

时间:2014-05-22 17:45:25

标签: javascript ruby-on-rails google-maps google-maps-api-3

对不起,这可能看起来像是一个愚蠢的问题,但现在第二天让我感到沮丧; ///

无论如何,我都可以看到地图。

这是创建新的测试项目 Application.html.erb

<!DOCTYPE html>
<html>
<head>
      <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #gmap { height: 100% }
    </style>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&libraries=geometry&v=3.7">
</script>
    <script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
      <%= stylesheet_link_tag    "application", :media => "all" %>
  <%= javascript_include_tag "maplace.min" %>
<script type="text/javascript">
$(function() {
    new Maplace({
        locations: [-34.397, 150.644],
        controls_on_map: false
    }).Load();
});
</script>
  <title>Maptest</title>
</head>
<body>
<div id="gmap"></div>
</body>
</html>

and it seems that all of the javascripts are loaded without any erros

似乎所有的javascripts都没有任何问题。请帮忙

2 个答案:

答案 0 :(得分:1)

我认为你需要为地图容器提供适当的尺寸。 从帖子中可以看出,你提到了:

#gmap { height: 100% }

但是,我猜它错过了宽度。您应该尝试将宽度添加到容器中。类似的东西:

#gmap { height: 100%;width:400px;} //Just a random dimension.

答案 1 :(得分:1)

我认为这应该有效,请尝试:

new Maplace({
    locations: [{
        lat: -34.397, 
        lon: 150.644
    }],
    controls_on_map: false
}).Load();
相关问题