Wrap geocode callback in ., fixing inconsistent updates

This commit is contained in:
Rohan Mitchell
2015-07-03 14:14:44 +10:00
parent 673635fdcb
commit 06c5ffb427

View File

@@ -53,12 +53,13 @@ Darkswarm.factory 'Enterprises', (enterprises, CurrentHub, Taxons, Dereferencer,
calculateDistanceGeo: (query) ->
Geo.geocode query, (results, status) =>
if status == Geo.OK
#console.log "Geocoded #{query} -> #{results[0].geometry.location}."
@setDistanceFrom results[0].geometry.location
else
console.log "Geocoding failed for the following reason: #{status}"
@resetDistance()
$rootScope.$apply =>
if status == Geo.OK
#console.log "Geocoded #{query} -> #{results[0].geometry.location}."
@setDistanceFrom results[0].geometry.location
else
console.log "Geocoding failed for the following reason: #{status}"
@resetDistance()
setDistanceFrom: (locatable) ->
for enterprise in @enterprises