2012-05-13 5 views
9

wunderground의 api 인 Leaflet and Cloudmade를 사용하여지도 아이콘에 날씨 아이콘을 표시하려고합니다. 텍스트를 표시하고 아이콘 이미지로 변수를 가져 왔지만 표시 방법을 모르겠습니다. 여기 내 코드는 다음과 같습니다전단지 팝업 이미지 표시

jQuery(document).ready(function($) { 
    $.ajax({ 
      url: "http://api.wunderground.com/api/cd48ac26fb540679/conditions/q/pws:KCASANFR128.json", 
      dataType: "jsonp", 
      success: function(parsed_json) { 
       var location = parsed_json['current_observation']['observation_location']['city']; 
       var temp_f = parsed_json['current_observation']['temp_f']; 
       var icon = parsed_json['current_observation']['icon_url']; 
       marker1.bindPopup("Current temperature in " +location+ " is: " + temp_f).openPopup(); 
     } 
    }); 
}); 

내가 더 성공이 시도 :

marker1.bindPopup(<img src=icon> "Current temperature in " +location+ " is: " + temp_f).openPopup(); 

어떤 제안? 당신은뿐만 아니라 따옴표 태그를 둘러싸고해야합니다 있도록

답변

10

마커의 bindPopup 방법은 그냥 문자열로 HTML 콘텐츠를합니다 -

marker1.bindPopup("<img src=" + icon_url + "/> Current temperature in " + location + " is: " + temp_f) 

같은 당신을 위해 작동해야한다.