【发布时间】:2018-10-13 00:16:21
【问题描述】:
我刚刚构建了一个使用 geofire 定位的 angularjs 应用程序。它在生产中完美运行,但是当我将它部署到 firebase 时出现问题。我相信错误应该来自这里
getLocations(radius: number, coords: Array<number>) {
console.log(radius, coords)
this.geoFire.query({
center: coords,
radius: radius
})
.on('key_entered', (userKey, location, distance) => {
//we need to check this because this.hits the behavioursubject already cached previous result and geofire fetches again each time we go back to homepage
const existAlready = this.hits.value.filter(h=>h.userKey === userKey)
if(existAlready.length > 0){
return
}
console.log(userKey)
const u = this.userList.query.ref
.child(`/${userKey}`)
.on('value',s=>{
const {name, address} = s.val()
console.log(s.val())
let hit = {
location,
distance,
name,
address,
userKey
}
let currentHits = this.hits.value
currentHits.push(hit)
this.hits.next(currentHits)
this.eventService.sendMessage(Constants.EVENT_MESSAGES.LOADING, true)
})
})
}
上述代码旨在在应用加载后立即获取我周围的位置。但是我得到了这个错误
@firebase/database:FIREBASE 警告:用户抛出异常 打回来。 TypeError:无法读取未定义的属性“myID”
错误只出现在生产中
【问题讨论】:
标签: angularjs firebase geofire