angular.module('app.mapEvents', ['pascalprecht.translate', 'ui-leaflet'])
.controller('MapEventsCtrl', function($scope, $http, $ionicModal,
$timeout, $ionicLoading, $filter,
leafletBoundsHelpers, $cordovaSocialSharing) {
//map
$scope.center= {
lat: 0,
lng: 0,
zoom: 1
};
$scope.markers=[];
$scope.tiles= {
url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
options: {
attribution: 'OpenStreetMap contributors'
}
};
$scope.events=[];
$scope.page=0;
$http.get(urlapi + 'events')
.then(function(data){
console.log('data success events');
console.log(data); // for browser console
//$scope.events = data.data; // for UI
$scope.events=data.data;
$scope.$broadcast('scroll.refreshComplete');//refresher stop
for(var i=0; i<$scope.events.length; i++)
{
if($scope.events[i].location)
{
var msg=""
+""+$scope.events[i].title + "
"
+""
+$scope.events[i].description+"";
$scope.markers.push({
lat: Number($scope.events[i].location.geo.lat),
lng: Number($scope.events[i].location.geo.long),
message: msg
});
$scope.center= {
lat: Number($scope.events[i].location.geo.lat),
lng: Number($scope.events[i].location.geo.long),
zoom: 12
};
}
}
}, function(data){
console.log('data error');
$scope.$broadcast('scroll.refreshComplete');//refresher stop
$ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 });
});
});