2014-03-06 2 views
0

Google지도 API v3의 맞춤 아이콘을로드하려고합니다. 실제Google 맞춤 아이콘이로드되지 않습니다.

다음 스크립트는 'application.html.erb'파일에
$(function(){ 

    function initialize() { 
    var mapOptions = { 
     center: new google.maps.LatLng(42.2542586, -83.8873974), 
     zoom: 10 
    }; 
    var map = new google.maps.Map(document.getElementById("map-canvas"), 
     mapOptions); 
    } 
    google.maps.event.addDomListener(window, 'load', initialize); 


    $('.valley').on('click', function(){ 

     var myLatlng = new google.maps.LatLng(42.000, -83.0073974); 
     var mapOptions = { 
     zoom: 14, 
     center: myLatlng 
     } 
     var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions); 
     var iconMarker = 'pin2.jpg' 
     var marker = new google.maps.Marker({ 
     position: myLatlng, 
     animation: google.maps.Animation.DROP, 
     icon: iconMarker, 
     map: map, 
     title:"Hello" 
     }); 
    }); 

}); 

이 꽤 똑바로 앞으로 <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=APIKEY&sensor=false"></script>

을 (난 내 apiKey에을 촬영했습니다)와 다음과 같이 내가 가진 코드는 지도가로드되지만 어떤 이유로 레일스 앱이 아이콘에 대해 .jpg을 찾지 못합니다. 여러 위치에 배치했는데 현재는 루트 폴더에 있습니다. 어떤 이유로 이미지 대신 파일 text/html로 파일을로드하려고합니다. 콘솔에서 오류가 나는 웹 페이지에 제대로로드 다른 이미지로 이미지를 교체하고 난 여전히 브라우저가 여기에 text/html loading as a text/html

으로로드하려고에 404를 얻을 수있다 404 error

답변

1

다음에서 시도하십시오 :

var iconMarker = '/assets/pin2.jpg'; 
관련 문제