简体   繁体   English

无法使地图与gmaps.js一起显示

[英]Can't get map to appear with gmaps.js

Sorry to bother you with sthg that simple but I really can't see what's wrong. 很抱歉打扰您这么简单,但是我真的看不到有什么问题。 I'm working on a website, I have HTML5&CSS3 knowledges but not much jQuery/javascript ones. 我在一个网站上工作,我了解HTML5&CSS3,但是对jQuery / javascript却了解不多。 I wanted to put in a gmap window like in my portfolio and so I tried to use this one : http://hpneo.github.io/gmaps/examples/basic.html . 我想像在投资组合中一样放入一个gmap窗口,因此我尝试使用以下窗口: http : //hpneo.github.io/gmaps/examples/basic.html

But all I've got on my webpage is a white and desperately empty square where my map should be. 但是,我在网页上得到的只是一个白色的,非常空的正方形,应该放在我的地图上。 I've checked if it "appears" by writing background-color:red in the map div, and it does appear red. 我通过在地图div中编写background-color:red来检查它是否“出现”,并且它的确显示为红色。

I linked these files in the header : 我将这些文件链接到标题中:

<script src="jQuery/gmaps.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script src="http://code.jquery.com/jquery.min.js"></script> 
<script type="text/javascript" src="jQuery/script.js"></script>

My map is in there : 我的地图在那儿:

<section>
   <h1> Où nous trouver ? </h1>
        <p> [Page en construction] </p> 
        <div id="basicmap"></div>
    </section>

My script.js : 我的script.js:

 $(document).ready(function(){ $(".diaporama").diaporama({ animationSpeed: "slow", delay:2 }); }); $(document).ready(function(){ var map = new GMaps({ div: 'basicmap', lat: 47.441396, lng: -2.196303, width: '500px', height: '500px', zoom: 12, zoomControl : true, zoomControlOpt: { style : 'SMALL', position: 'TOP_LEFT' }, panControl : false, }); map.addMarker({ lat: 47.441396, lng: -2.196303, title: 'Résidence Les Ajoncs' }); }); $(function() { $("#submit").hide(); $("#page-changer select").change(function() { window.location = $("#page-changer select option:selected").val(); }) }); 

And finally a bit of my CSS : 最后是我的CSS:

#basicmap
{
    display: block;
    width: 500px;
    height: 500px;
    margin: 0 auto;
    -moz-box-shadow: 0px 5px 20px #ccc;
    -webkit-box-shadow: 0px 5px 20px #CCC;
    box-shadow: 0px 5px 20px #CCC;
}

(Sorry I think I've messed up a bit with the code insertions method in this post haha.) (对不起,我想我已经把本文中的代码插入方法弄糊涂了。)

I may be tired or it's something I don't know about (because I haven't got a lot of web programming knowledge and I was a bit in a hurry), idk, but I've ran out of ideas to solve this problem. 我可能会很累,或者我不知道这件事(因为我没有太多的网络编程知识,所以我有点着急),idk,但是我已经没有解决这个问题的想法了。

Soooo. SOOOO。 Many thanks in advance if you can save me \\°/ 如果您能救我\\\\ /

Looks to me like you are not including the gmaps.js library. 在我看来,您不包括gmaps.js库。 The snippet below works for me (which is based off your code, but does include the gmaps.js library). 下面的代码段对我有用(基于您的代码,但确实包含gmaps.js库)。

 $(document).ready(function() { var map = new GMaps({ div: '#basicmap', lat: 47.441396, lng: -2.196303, width: '500px', height: '500px', zoom: 12, zoomControl: true, zoomControlOpt: { style: 'SMALL', position: 'TOP_LEFT' }, panControl: false, }); map.addMarker({ lat: 47.441396, lng: -2.196303, title: 'Résidence Les Ajoncs' }); }); $(function() { $("#submit").hide(); $("#page-changer select").change(function() { window.location = $("#page-changer select option:selected").val(); }) }); 
 #basicmap { display: block; width: 500px; height: 500px; margin: 0 auto; -moz-box-shadow: 0px 5px 20px #ccc; -webkit-box-shadow: 0px 5px 20px #CCC; box-shadow: 0px 5px 20px #CCC; } 
 <script src="https://maps.googleapis.com/maps/api/js?v=3"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <script src="https://cdn.rawgit.com/hpneo/gmaps/master/gmaps.js"></script> <section> <h1> Où nous trouver ? </h1> <p>[Page en construction]</p> <div id="basicmap"></div> </section> 

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

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