当前,我在firebase中具有以下节点“ Zones”,这意味着停车场的区域:
在该对象中,我必须保存一个名为“ parking”的对象,该对象必须包含GeoFire.Set库提供的lat,long和geohash属性。我目前以这种方式单独保存它:
var firebaseRef = firebase.database().ref('zona');
var geoFire = new GeoFire(firebaseRef);
geoFire.set("some_key9", [37.79, -122.41]).then(function() {
//console.log("Provided key has been added to GeoFire");
}, function(error) {
//console.log("Error: " + error);
});
如何使“区域”节点保存我在geoFire.set更新属性中发送的内容,使其看起来像这样:
zona_parqueo1:{
g: "9q8yyrry8q",
l:{
0: 37.79,
1: -122.41
},
parqueos: {
parqueo1: {
'nombre': 'parqueo1'
},
parqueo2: {
'nombre': 'parqueo2'
}
}
同样,我使用'on'方法获取值并创建具有经度和纬度的标记:
geoQuery.on("key_entered", function(key, location, distance) {
//console.log(key + " entered query at " + location + " (" + distance + " km from center)");
//console.log("LATITUD Y LONGITUD");
console.log(location);
let marker = {
lat: location[0],
lng: location[1]
}
vm.markers.push(marker);
});
},