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.

59 lines
2.0 KiB

  1. angular.module('app.mapEvents', ['pascalprecht.translate', 'ui-leaflet'])
  2. .controller('MapEventsCtrl', function($scope, $http, $ionicModal,
  3. $timeout, $ionicLoading, $filter,
  4. leafletBoundsHelpers, $cordovaSocialSharing) {
  5. //map
  6. $scope.center= {
  7. lat: 0,
  8. lng: 0,
  9. zoom: 1
  10. };
  11. $scope.markers=[];
  12. $scope.tiles= {
  13. url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
  14. options: {
  15. attribution: '<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
  16. }
  17. };
  18. $scope.events=[];
  19. $scope.page=0;
  20. $http.get(urlapi + 'events')
  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.events=data.data;
  26. $scope.$broadcast('scroll.refreshComplete');//refresher stop
  27. for(var i=0; i<$scope.events.length; i++)
  28. {
  29. if($scope.events[i].location)
  30. {
  31. var msg="<a href='#/app/events/"+$scope.events[i]._id+"'>"
  32. +"<h4>"+$scope.events[i].title + "</h4>"
  33. +"<img src='"+$scope.events[i].img+"' style='width:100%;'>"
  34. +$scope.events[i].description+"</a>";
  35. $scope.markers.push({
  36. lat: Number($scope.events[i].location.geo.lat),
  37. lng: Number($scope.events[i].location.geo.long),
  38. message: msg
  39. });
  40. $scope.center= {
  41. lat: Number($scope.events[i].location.geo.lat),
  42. lng: Number($scope.events[i].location.geo.long),
  43. zoom: 12
  44. };
  45. }
  46. }
  47. }, function(data){
  48. console.log('data error');
  49. $scope.$broadcast('scroll.refreshComplete');//refresher stop
  50. $ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 });
  51. });
  52. });