Database Reference
In-Depth Information
layout=applayout, title="Location",
productTitle=productNode["title"], locations=locations,
mappedUserLocation=userlocations)
# no product provided
else:
# get locations
locations = Location().locations_within_distance(graph_db,
UserLocation().get_lq(ul, distance),
ul,"business")
return template('public/templates/graphs/location/index.html',
layout=applayout, title="Location",
locations=locations, mappedUserLocation=userlocations)
# return search template for locations
else:
return template('public/templates/graphs/location/index.html', layout=applayout,
title="Location",
mappedUserLocation=userlocations)
Search for Nearby Locations
To search for nearby locations, as shown in Figure
9-16
, use the current user's location, obtained by calling the
get_user_location
method in the
UserLocation
class, and then by calling the
locations_within_distance
. The
locations_within_distance
method in
Location
class uses a method called
distance
to return a string value of the
distance between the starting point and the respective location (Listing 9-39).
Figure 9-16.
Searching for Locations within a certain distance of User location