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.

71 lines
2.3 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, $cordovaSocialSharing) {
  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. $scope.share = function(){
  49. var message = "hola, això ho comparteixo";
  50. var subject = 'compartició';
  51. var file= ['',''];
  52. var link = "http://duckduckgo.com";
  53. $cordovaSocialSharing
  54. .share(message, subject, file, link) // Share via native share sheet
  55. .then(function(result) {
  56. // Success!
  57. }, function(err) {
  58. // An error occured. Show a message to the user
  59. });
  60. };
  61. });