mirror of
https://github.com/arnaucube/openEventsPlatformApp.git
synced 2026-02-07 03:36:44 +01:00
implemented geolocation to events create and on event show
This commit is contained in:
@@ -36,12 +36,12 @@ angular.module('app.event', ['pascalprecht.translate', 'ui-leaflet'])
|
||||
$scope.markers.push({
|
||||
lat: Number($scope.event.location.geo.lat),
|
||||
lng: Number($scope.event.location.geo.long),
|
||||
message: $scope.event.location.name
|
||||
message: $scope.event.location.direction
|
||||
});
|
||||
$scope.center= {
|
||||
lat: (Number($scope.travel.from.lat)+Number($scope.travel.to.lat))/2,
|
||||
lng: (Number($scope.travel.from.long)+Number($scope.travel.to.long))/2,
|
||||
zoom: 4
|
||||
lat: Number($scope.event.location.geo.lat),
|
||||
lng: Number($scope.event.location.geo.long),
|
||||
zoom: 16
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
angular.module('app.newEvent', ['pascalprecht.translate'])
|
||||
angular.module('app.newEvent', ['pascalprecht.translate', 'ui-leaflet'])
|
||||
|
||||
.controller('NewEventCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading, $filter) {
|
||||
.controller('NewEventCtrl', function($scope, $http, $ionicModal, $timeout,
|
||||
$ionicLoading, $filter, leafletData, leafletBoundsHelpers) {
|
||||
|
||||
$scope.event={};
|
||||
$scope.event.categories=[{name: "prova"}];
|
||||
$scope.event.location={
|
||||
direction: "",
|
||||
geo: {
|
||||
lat: "",
|
||||
long: "",
|
||||
name: ""
|
||||
}
|
||||
};
|
||||
$scope.postEvent = function(){
|
||||
$http({
|
||||
url: urlapi + 'events',
|
||||
@@ -11,6 +20,7 @@ angular.module('app.newEvent', ['pascalprecht.translate'])
|
||||
data: $scope.event
|
||||
})
|
||||
.then(function(data) {
|
||||
$scope.event={};
|
||||
window.location.href="#/app/events";
|
||||
},
|
||||
function(response) { // optional
|
||||
@@ -18,4 +28,45 @@ angular.module('app.newEvent', ['pascalprecht.translate'])
|
||||
console.log(response);
|
||||
});
|
||||
};
|
||||
|
||||
/* map */
|
||||
|
||||
$scope.center= {
|
||||
lat: 0,
|
||||
lng: 0,
|
||||
zoom: 1
|
||||
};
|
||||
$scope.markers=new Array();
|
||||
$scope.tiles= {
|
||||
url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
||||
options: {
|
||||
attribution: '<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||
}
|
||||
};
|
||||
$scope.getGeo = function(){
|
||||
|
||||
$scope.markers=[];
|
||||
console.log($scope.event.location.direction);
|
||||
$http.get('http://nominatim.openstreetmap.org/search?q=' + $scope.event.location.direction + '&format=json&limit=1')
|
||||
.then(function(data) {
|
||||
console.log(data);
|
||||
if(data.data[0])
|
||||
{
|
||||
$scope.event.location.geo.lat=data.data[0].lat;
|
||||
$scope.event.location.geo.long=data.data[0].lon;
|
||||
//$scope.newtravel.from.name=data.data[0].display_name;
|
||||
$scope.markers.push({
|
||||
lat: Number(data.data[0].lat),
|
||||
lng: Number(data.data[0].lon),
|
||||
message: $scope.event.location.direction
|
||||
});
|
||||
$scope.center= {
|
||||
lat: Number(data.data[0].lat),
|
||||
lng: Number(data.data[0].lon),
|
||||
zoom: 16
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user