gpt4 book ai didi

jquery - 通过 gmap3 显示 map 时出错

转载 作者:行者123 更新时间:2023-12-01 04:57:55 26 4
gpt4 key购买 nike

我正在努力在我的网络屏幕上显示 map 。但在显示时遇到一些错误。

错误:-

TypeError: $("#driver_map").gmap3 is not a function

代码:-

%script{:src=>'../assets/public/js/gmap3.js'}
%script{:src=>'http://maps.google.com/maps/api/js?sensor=false' :type=>'text/javascript'}
%script{:src=>'../assets/public/js/jquery-1.6.4.js'}

%html
%head
%body
%div{:id=>"driver_map"}

:javascript
$(function(){
$('#driver_map').gmap3(
{ action:'init',
options:{
center:[46.578498,2.457275],
zoom: 5
}
},
{ action: 'addMarkers',
markers:[
{lat:48.8620722, lng:2.352047, data:'Paris !'},
{lat:46.59433,lng:0.342236, data:'Poitiers : great city !'},
{lat:42.704931, lng:2.894697, data:'Perpignan ! <br> GO USAP !'}
],
}
);
});

请帮我解决这个错误。

最佳答案

gmap3.js 使用 jQuery,因此需要在 jquery-1.6.4.js 之后加载。所有示例都按以下顺序加载内容:

  1. jQuery
  2. Google map
  3. gmap3

因此可能还需要在 Google map JavaScript 之后加载。

尝试调整加载顺序:

%script{:src=>'../assets/public/js/jquery-1.6.4.js'}
%script{:src=>'http://maps.google.com/maps/api/js?sensor=false' :type=>'text/javascript'}
%script{:src=>'../assets/public/js/gmap3.js'}

我还建议不要使用亲属路径,它们只会造成麻烦。您最好使用像 '/assets/public/js/jquery-1.6.4.js' 这样的绝对路径,这样您就不必关心自己在哪里。

关于jquery - 通过 gmap3 显示 map 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13028895/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com