Database Reference
In-Depth Information
Listing 11-51.
getUserLocation in UserImpl
public MappedUserLocation
getUserLocation
(String currentusername) {
MappedUserLocation mappedUserLocation = null;
List<MappedUserLocation> mappedUserLocations =
mappedUserLocationRepository.getUserLocation
(currentusername);
if (mappedUserLocations.size() > 0) {
mappedUserLocation = mappedUserLocations.get(0);
}
return mappedUserLocation;
}
Search for Nearby Locations
To search for nearby locations (Figure
11-16
), use the current user's location, obtained with
getUserLocation
,
and then use the
returnLocationsWithinDistance
method. The
returnLocationsWithinDistance
method in
LocationImpl
(Listing 11-52) also uses a method called
addDistanceTo
to place a string value of the distance between
the starting point and the respective location.
Figure 11-16.
Searching for Locations within a certain distance of User location