Commit 7fe52066 authored by Vikas's avatar Vikas

Update WeatherWidgetContents.js

parent c284af54
//this component will be called for DETAIL_SUMMARY_WIDGET registration. //this component will be called for DETAIL_SUMMARY_WIDGET registration.
//this example is without map
var Contacts_Component_WeatherWidgetContents = VTAP.Component.Core.extend({ var Contacts_Component_WeatherWidgetContents = VTAP.Component.Core.extend({
data() { data() {
weather_data : '' weather_data : ''
...@@ -12,26 +13,11 @@ var Contacts_Component_WeatherWidgetContents = VTAP.Component.Core.extend({ ...@@ -12,26 +13,11 @@ var Contacts_Component_WeatherWidgetContents = VTAP.Component.Core.extend({
(error, response) => { (error, response) => {
if(response && response.content) { if(response && response.content) {
this.weather_data = JSON.parse(response.content); this.weather_data = JSON.parse(response.content);
setTimeout(() => {
this.showMap();
}, 2000);
} }
}); });
}); });
}, },
methods : { methods : {
//shows open street map based on the lat lng received from openweather api
showMap() {
var element = document.getElementById('osm-map');
var map = L.map(element);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
// set's GPS coordinates.
var target = L.latLng(this.data.coord.lat, this.data.coord.lon);
map.setView(target, 13);
L.marker(target).addTo(map);
},
getDisplayTime(timestamp) { getDisplayTime(timestamp) {
let d = new Date(timestamp * 1000).toISOString().slice(0, 19).replace('T', ' ').split(' '); let d = new Date(timestamp * 1000).toISOString().slice(0, 19).replace('T', ' ').split(' ');
return d[1]; return d[1];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment