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. 'use strict';
  2. angular.module('app.main', ['ngRoute', 'ui-leaflet'])
  3. .config(['$routeProvider', function($routeProvider) {
  4. $routeProvider.when('/main', {
  5. templateUrl: 'views/main/main.html',
  6. controller: 'MainCtrl'
  7. });
  8. }])
  9. .controller('MainCtrl', function($scope, $http) {
  10. //map
  11. $scope.center = {};
  12. $scope.bounds = {};
  13. $scope.markers = [];
  14. $scope.paths = [];
  15. $scope.tiles = {
  16. //url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
  17. url: "http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",
  18. // més estils https://leaflet-extras.github.io/leaflet-providers/preview/
  19. options: {
  20. attribution: '<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
  21. }
  22. };
  23. //var antennaIcon = L.icon({
  24. var antennaIcon = {
  25. iconUrl: 'img/antenna.png',
  26. iconSize: [50, 50], // size of the icon
  27. iconAnchor: [25, 50], // point of the icon which will correspond to marker's location
  28. };
  29. $http.get(urlapi + 'cells/43.73429/7.41841/43.73210/7.42196')
  30. .then(function(data) {
  31. console.log('data success');
  32. console.log(data);
  33. $scope.cells = data.data;
  34. //draw markers on map
  35. $scope.markers = [];
  36. for (var i = 0; i < $scope.cells.length; i++) {
  37. $scope.markers.push({
  38. lat: Number($scope.cells[i].lat),
  39. lng: Number($scope.cells[i].lon),
  40. message: $scope.cells[i].mcc,
  41. icon: antennaIcon
  42. });
  43. }
  44. $scope.center = {
  45. lat: (Number($scope.cells[0].lat) + Number($scope.cells[0].lat)) / 2,
  46. lng: (Number($scope.cells[0].lon) + Number($scope.cells[0].lon)) / 2,
  47. zoom: 16
  48. };
  49. }, function(data) {
  50. console.log('data error');
  51. });
  52. });