2012-10-23 3 views
2

웹 화면에지도를 표시하기 위해 노력하고 있습니다. 하지만 그것을 표시하는 동안 일부 오류가 발생했습니다.gmap3을 통해지도를 표시하는 중 오류가 발생했습니다.

오류 : -

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 !'} 
     ],    
     } 
    ); 
    }); 

날이 오류를 해결하는 데 도움이 바랍니다.

답변

1

gmap3.js은 jQuery를 사용하므로 jquery-1.6.4.js 이후에로드해야합니다. 모든 예제는이 순서대로 일을로드 :

  • gmap3
    1. jQuery를
    2. Google지도를 그래서 그것뿐만 아니라 Google지도 자바 스크립트 후로드해야 할 수도 있습니다.

      은로드 순서를 조정 해보십시오 :

      나는 또한 친척 경로를 사용에 대해 권하고 싶습니다
      %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'과 같은 절대 경로를 사용하면 자신이 어디에 있는지 신경 쓸 필요가 없습니다.

    관련 문제