我是Firebase和Google Maps API的新用户。我想在Google Map中集成Firebase,以便在doc中实时进行热图。每当我点击地图时,数据都会添加到Firebase数据库中,但数据或热图不会显示。
function initAuthentication(onAuthSuccess) {
firebase.authAnonymously(function(error, authData) {
if (error) {
console.log('Login Failed!', error);
} else {
data.sender = authData.uid;
onAuthSuccess();
}
}, {remember: 'sessionOnly'});
}
来自控制台的错误如下:
Login Failed! Error: Projects created at console.firebase.google.com must use the new Firebase Authentication SDKs available from firebase.google.com/docs/auth/
at firebase.js:163
at XMLHttpRequest.e.onreadystatechange (firebase.js:147)
我有来自Google文档的Firebase脚本:
<script src="https://cdn.firebase.com/js/client/2.3.2/firebase.js"></script>
我尝试将脚本更改为
<script src="https://www.gstatic.com/firebasejs/3.6.2/firebase.js"></script>
我还将Firebase中的规则更改为:
{
"rules": {
".read": true,
".write": true
}
}
提前致谢。
答案 0 :(得分:0)
尝试更改此内容:
<script src="https://www.gstatic.com/firebasejs/4.6.0/firebase.js"></script>
并更改匿名身份验证的代码:
function initAuthentication(onAuthSuccess) {
firebase.auth().signInAnonymously().catch(function(error) {
if (error) {
console.log('Login Failed!', error);
} else {
data.sender = authData.uid;
onAuthSuccess();
}
});
}
您还需要将Firebase添加到项目中,请参阅以下链接: https://firebase.google.com/docs/web/setup