diff --git a/pogom/app.py b/pogom/app.py index 53fedf5439..9fd5342999 100755 --- a/pogom/app.py +++ b/pogom/app.py @@ -97,7 +97,12 @@ def next_loc(self): def list_pokemon(self): # todo: check if client is android/iOS/Desktop for geolink, currently only supports android pokemon_list = [] - origin_point = LatLng.from_degrees(config['ORIGINAL_LATITUDE'], config['ORIGINAL_LONGITUDE']) + + # Allow client to specify location + lat = request.args.get('lat', config['ORIGINAL_LATITUDE'], type=float) + lon = request.args.get('lon', config['ORIGINAL_LONGITUDE'], type=float) + origin_point = LatLng.from_degrees(lat, lon) + for pokemon in Pokemon.get_active(None, None, None, None): pokemon_point = LatLng.from_degrees(pokemon['latitude'], pokemon['longitude']) diff = pokemon_point - origin_point @@ -110,7 +115,8 @@ def list_pokemon(self): 'name': pokemon['pokemon_name'], 'card_dir': direction, 'distance': int(origin_point.get_distance(pokemon_point).radians * 6366468.241830914), - 'time_to_disappear': '%dm %ds' % (divmod((pokemon['disappear_time']-datetime.utcnow()).seconds, 60)), + 'time_to_disappear': '%d min %d sec' % (divmod((pokemon['disappear_time']-datetime.utcnow()).seconds, 60)), + 'disappear_time': pokemon['disappear_time'], 'latitude': pokemon['latitude'], 'longitude': pokemon['longitude'] } @@ -118,8 +124,8 @@ def list_pokemon(self): pokemon_list = [y[0] for y in sorted(pokemon_list, key=lambda x: x[1])] return render_template('mobile_list.html', pokemon_list=pokemon_list, - origin_lat=config['ORIGINAL_LATITUDE'], - origin_lng=config['ORIGINAL_LONGITUDE']) + origin_lat=lat, + origin_lng=lon) class CustomJSONEncoder(JSONEncoder): diff --git a/templates/mobile_list.html b/templates/mobile_list.html index ba00bfa08f..40259bf809 100644 --- a/templates/mobile_list.html +++ b/templates/mobile_list.html @@ -2,20 +2,70 @@ -

Nearby Pokémon ↻

-{% for pokemon in pokemon_list %} +
+

Nearby Pokémon

+ +
+{% for pokemon in pokemon_list[:20] %} -

{{pokemon.distance}}m ({{pokemon.card_dir}})

{{pokemon.time_to_disappear}}
+

{{pokemon.name}} - {{pokemon.distance}}m ({{pokemon.card_dir}})

{% endfor %} -scan location +origin location +