You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.9 KiB

  1. angular.module('app.event', ['pascalprecht.translate', 'ui-leaflet'])
  2. .controller('EventCtrl', function($scope, $http, $ionicModal,
  3. $stateParams, $timeout, $ionicLoading, $filter,
  4. leafletData, leafletBoundsHelpers) {
  5. $scope.center= {
  6. lat: 0,
  7. lng: 0,
  8. zoom: 1
  9. };
  10. $scope.markers=[];
  11. $scope.tiles= {
  12. url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
  13. options: {
  14. attribution: '<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
  15. }
  16. };
  17. $scope.event={};
  18. $scope.doRefresh = function() {
  19. /* events refresh: */
  20. $http.get(urlapi + 'events/id/'+ $stateParams.eventid)
  21. .then(function(data){
  22. console.log('data success events');
  23. console.log(data); // for browser console
  24. //$scope.events = data.data; // for UI
  25. $scope.event=data.data;
  26. $scope.$broadcast('scroll.refreshComplete');//refresher stop
  27. if($scope.event.location)
  28. {
  29. $scope.markers=[];
  30. $scope.markers.push({
  31. lat: Number($scope.event.location.geo.lat),
  32. lng: Number($scope.event.location.geo.long),
  33. message: $scope.event.location.name
  34. });
  35. $scope.center= {
  36. lat: (Number($scope.travel.from.lat)+Number($scope.travel.to.lat))/2,
  37. lng: (Number($scope.travel.from.long)+Number($scope.travel.to.long))/2,
  38. zoom: 4
  39. };
  40. }
  41. }, function(data){
  42. console.log('data error');
  43. $scope.$broadcast('scroll.refreshComplete');//refresher stop
  44. $ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 });
  45. });
  46. };
  47. $scope.doRefresh();
  48. });