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.

54 lines
1.8 KiB

  1. angular.module('app.user', ['pascalprecht.translate', 'ui-leaflet'])
  2. .controller('UserCtrl', 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.user={};
  18. $scope.doRefresh = function() {
  19. /* events refresh: */
  20. $http.get(urlapi + 'users/id/'+ $stateParams.userid)
  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.user=data.data;
  26. $scope.$broadcast('scroll.refreshComplete');//refresher stop
  27. if($scope.user.location)
  28. {
  29. $scope.markers=[];
  30. $scope.markers.push({
  31. lat: Number($scope.user.location.geo.lat),
  32. lng: Number($scope.user.location.geo.long),
  33. message: $scope.user.location.name
  34. });
  35. $scope.center= {
  36. lat: Number($scope.user.location.geo.lat),
  37. lng: Number($scope.user.location.geo.long),
  38. zoom: 16
  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. });