【问题标题】:Gmap , jQuery and google mapsGmap , jQuery 和谷歌地图
【发布时间】:2014-09-20 18:33:13
【问题描述】:

我正在尝试向我的网站添加一个简单的谷歌地图,其中包括 jQuery 。 我得到的唯一错误是:

GET http://code.jquery.com/jquery.min.map 404 (Not Found)  

这里是相关的代码部分,所有的插件都在头:

<!--jquery ,js scripts  -->
    <link rel="stylesheet" href="styles.css" />
    <link rel="stylesheet"href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css" />
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
    <!--js scripts -->
    <script src="jsCode.js"></script> 
    <script src ="sirJson.js"></script>
    <!--gMap plugin API -->
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
    <script src = "gmap.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>

Javascript 代码:

$( document ).ready(function() {
        var map = new GMaps({
        el: '#map',
        lat: 51.5073346,
        lng: -0.1276831,
        zoom: 12,
        zoomControl : true,
        zoomControlOpt: {
        style : 'SMALL',
        position: 'TOP_LEFT'
        },
    panControl : false,
    });

最后是我的 html,地图的 jQuery div:

<div data-role="main" class="ui-content">
        <div id="map"></div>
    </div>

修正错误 - jQuery's jquery-1.10.2.min.map is triggering a 404 (Not Found)

但地图仍然没有显示在地图页面中。

JS代码:

$( document ).ready(function() {
        var map = new GMaps({
        el: '#map',
        lat: 51.5073346,
        lng: -0.1276831,
        zoom: 12,
        zoomControl : true,
        zoomControlOpt: {
        style : 'SMALL',
        position: 'TOP_LEFT'
        },
    panControl : false,
    });

map - div 元素。

【问题讨论】:

    标签: javascript jquery google-maps jquery-plugins jquery-gmap3


    【解决方案1】:

    我建议看看this 它清楚地解释了这个错误是什么

    编辑

    更具体。要摆脱该错误,您需要做的事情如下(我将使用 jquery v1.11.0):

    1. 下载地图文件和 jQuery 的未压缩版本。将它们与缩小版本(同一文件夹)放在一起。大家可以here

    2. minified(仅缩小后的)版本包含到您的 HTML(标头中的脚本标记)中。

    3. 检查您首选的 js 调试控制台,确保错误已消失。

    希望这能让事情更清楚。

    祝你好运。

    【讨论】:

    • 还是有同样的问题 - - 错误资源解释为脚本,但使用 MIME 类型 text/plain 传输:"file:///C:/Users/Itsik/Desktop/FIXBAY/jquery- 2.1.1.min.map”。 fixBay.html:17 Uncaught SyntaxError: Unexpected token: jquery-2.1.1.min.map:1 GET code.jquery.com/jquery.min.map 404 (Not Found) fixBay.html:14
    • @ItsikMauyhas 根据您的帖子,您似乎已经设法摆脱了 404 错误。我在您的代码中看不到任何问题,并且显示了地图(如您在此处看到的 fiddle )。我唯一能想到的是你的 css 不正确(例如,你没有给 div 任何高度)。我还注意到,如果您使用百分比而不是固定高度,则地图不会显示。
    • 谢谢你,这解释了我需要知道的每一件事。
    【解决方案2】:

    为什么要使用 2 个 jquery 脚本。

    首先只使用下面的一个脚本

     <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    
    
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
    

    你最终的脚本结构是这样的:

     <link rel="stylesheet" href="styles.css" />
        <link rel="stylesheet"href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css" />
        <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
        <!--js scripts -->
        <script src="jsCode.js"></script> 
        <script src ="sirJson.js"></script>
        <!--gMap plugin API -->
        <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
        <script src = "gmap.js"></script>
    

    【讨论】:

    • Uncaught SyntaxError: Unexpected token : jquery-1.9.1.min.map:1 GET code.jquery.com/jquery.min.map 404(未找到)code.jquery.com/jquery。 min.map:1 - 错误,如何包含此文件以使其正常工作?以及禁用什么,以便它开始使用它
    【解决方案3】:

    jQuery 包含一个sourceMappingURL,以便更轻松地调试缩小代码,您可以从http://code.jquery.com/jquery-1.9.1.min.map 获取映射文件。

    【讨论】:

    • 那么添加这个文件后,我可以删除哪些 jQuery 链接?
    • Uncaught SyntaxError: Unexpected token : jquery-1.9.1.min.map:1 GET code.jquery.com/jquery.min.map 404 (Not Found) code.jquery.com/jquery.min.map:1 - 错误,如何包含此文件以使其正常工作?以及禁用什么,以便它开始使用它。
    • @ItsikMauyhas 把它放在你有 jQuery 的地方。
    猜你喜欢
    • 2017-02-01
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 2015-01-14
    • 2012-06-20
    • 2011-03-02
    • 1970-01-01
    相关资源
    最近更新 更多