我正在尝试使用wunderground的api,Leaflet和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();
}
});
});
Run Code Online (Sandbox Code Playgroud)
我试过这个没有成功:
marker1.bindPopup( <img src=icon> "Current temperature in " +location+ " is: " + temp_f).openPopup();
Run Code Online (Sandbox Code Playgroud)
有什么建议?
我有一个数组:
[1, 2, 3, 6, 8, 9, 10, 23, 34, 35, 36, 45, 50, 51, ...]
Run Code Online (Sandbox Code Playgroud)
我正在尝试删除每组连续的数字,所以我最终得到:
[6, 23, 45, ...]
Run Code Online (Sandbox Code Playgroud)
我正在寻找序列ID中的异常.有没有人有建议?
我的初始尝试只检查每个元素之前的id:
non_consecutive_ids = []
ids.each_with_index do |x, i|
unless x == ids[i-1] + 1
non_consecutive_ids << x
end
end
Run Code Online (Sandbox Code Playgroud)
我认为我缺少的是检查数组中的下一个元素是否比当前元素多1.