Support Center

Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

how to use widgets

Christopher Lucas Jun 09, 2017 08:33AM UTC

Hello,
I'm using this api for a school project. I getting the hang of it slowly but i can't understand the widgets. I'm trying put my informations in it but I keep get errors. i was hoping that somebody could explain to me how to use the code that is given.
have a nice day
Chris

Up 0 rated Down
Maxim Gushcho Jun 09, 2017 10:04AM UTC OpenWeatherMap Agent

Hello Chris,

Could you please check how you input the data. It should be without empty spaces in the fields.
If errors appears again then attach the screen and provide an API key.

Up 0 rated Down
Christopher Lucas Jun 09, 2017 11:35AM UTC
Hi, thanks for the advice. I found the list of parameters on the website and it help me. Could you help me understand this? Because now I want to add the widget to a view and I keep getting a text content is null.

window.myWidgetParam ? window.myWidgetParam : window.myWidgetParam = [];
window.myWidgetParam.push({...});
Up 0 rated Down
Christopher Lucas Jun 09, 2017 11:43AM UTC
This is my code:
function _effectuerWeather(){
var city = $('#location').val();
if (city !== '') {
$.ajax({
url: 'http://api.openweathermap.org/data/2.5/weather?q=' + city + '&units=metric' + "&APPID=f1206b03d1c67d06c3697b0eff1e3bde",
type: "GET",
dataType: 'jsonp',
success: function (data) {
console.log(data);
$('openweathermap-widget-24').html(_show(data));
_loadView('weather');
}
});
;
} else {
$('#error').html('Field cannot be empty');
}
}
function _show(data) {
window.myWidgetParam ? window.myWidgetParam : window.myWidgetParam = [];
window.myWidgetParam.push({
id: 24,
cityid: data.id,
appid: 'f1206b03d1c67d06c3697b0eff1e3bde',
units: 'metric',
containerid: 'openweathermap-widget-24'
}); (function() {
var script = document.createElement('script');
script.async = true;
script.src = "http://openweathermap.org/themes/openweathermap/assets/vendor/owm/js/weather-widget-generator.js";
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(script, s);
})();
}

Post Your Public Answer

Your name (required)
Your email address (required)
Answer (required)
9eda11838f597e7a95b6a1c991dcae0a@openweathermap.desk-mail.com
https://cdn.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete