Add geolocation to related data

I am currently required to make a project wherein hotels are supposed to be stored along with their locations. I’m using Google Maps API to retrieve the latitude and longitude, and creating a geopoint on Backendless. I have also created a georelation in my hotels table. But while creating a hotel, I’m unable to add the geolocation relation. How do I do so?

Here’s my code:

.controller('AgAddCtrl', function($scope, $state, $http) {
  console.log("Agent Add");
  console.log($state.params.user);
  $scope.hotelReg = function() {
    var address = $scope.hName + ',' + $scope.hLocality + ',' + $scope.hCity;
    var latitude;
    var longitude;
    var user = $state.params.user;
    var url = "https://maps.googleapis.com/maps/api/geocode/json?key=AIzaSyCv9qLcpwSqElOvsLVaZNIsY161GU3Y7QY&address=" + address;
    $http.get(url)
      .success(function(data) {
        latitude = data.results[0].geometry.location.lat;
        longitude = data.results[0].geometry.location.lng;
        console.log(latitude);
        console.log(longitude);
        var point = {
          latitude: latitude,
          longitude: longitude
        }
        Backendless.Geo.addPoint( point )
         .then( function( savedGeoPoint ) {
           $scope.geo = savedGeoPoint.objectId;
           console.log( "geo point saved " + savedGeoPoint.objectId );
         })
         .catch( function( error ) {
           console.log( "error - " + error.message );
         });
        Backendless.Data.of("Hotels").save({
          name: $scope.hName,
          locality: $scope.hLocality,
          city: $scope.hCity,
          amenities: $scope.hAmenities,
          latitude: latitude,
          longitude: longitude,
          hotel_geo: $scope.geo,
          agent_email: user.email
        }).then( function( savedObject ) {
              console.log("success");
            })
          .catch( function( error ) {
              console.log("error upload" + error.message);
            });
      })
      .error( function(error) {
        console.log("error map");
      })
  }
})

Hi Saurav,

Please see the following section in the documentation which describes this very subject:
https://backendless.com/docs/android/doc.html#data_relations_with_geo_points

Regards,
Mark

Can this not be done through the code, instead of having to use the console for every single point?

Yes, it can. If you scroll down the page (same section in the docs), you will see the code.