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.

51 lines
1.7 KiB

  1. angular.module('app.place', ['pascalprecht.translate', 'ui-leaflet'])
  2. .controller('PlaceCtrl', function($scope, $http, $ionicModal, $timeout,
  3. $ionicLoading, $filter, leafletData, leafletBoundsHelpers) {
  4. $scope.center= {
  5. lat: 0,
  6. lng: 0,
  7. zoom: 1
  8. };
  9. $scope.markers=new Array();
  10. $scope.tiles= {
  11. url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
  12. options: {
  13. attribution: '<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
  14. }
  15. };
  16. $scope.place={
  17. location:{
  18. direction:"",
  19. geo:{
  20. lat:"",
  21. long:""
  22. }
  23. }
  24. };
  25. $scope.getGeo = function(){
  26. $scope.markers=[];
  27. console.log($scope.place.location.direction);
  28. $http.get('http://nominatim.openstreetmap.org/search?q=' + $scope.place.location.direction + '&format=json&limit=1')
  29. .then(function(data) {
  30. console.log(data);
  31. if(data.data[0])
  32. {
  33. $scope.place.location.geo.lat=data.data[0].lat;
  34. $scope.place.location.geo.long=data.data[0].lon;
  35. //$scope.newtravel.from.name=data.data[0].display_name;
  36. $scope.markers.push({
  37. lat: Number(data.data[0].lat),
  38. lng: Number(data.data[0].lon),
  39. message: $scope.place.location.direction
  40. });
  41. $scope.center= {
  42. lat: Number(data.data[0].lat),
  43. lng: Number(data.data[0].lon),
  44. zoom: 16
  45. };
  46. }
  47. });
  48. };
  49. });