public static GeoLocation getLocationValue(DataSnapshot dataSnapshot) { try { return(GeoLocationObjConverter.getInstance().parse(dataSnapshot.Value)); } catch (NullReferenceException e) { return(null); } catch (InvalidCastException e) { return(null); } }
/** * Sets the location for a given key. * * @param key The key to save the location for * @param location The location of this key */ public void setLocation(string key, GeoLocation location) { if (key == null) { throw new NullReferenceException(); } DatabaseReference keyRef = this.getDatabaseRefForKey(key); GeoHash geoHash = new GeoHash(location); //Dictionary<string, object> updates = new Dictionary<string, object>(); //updates.Add("g", geoHash.getGeoHashString()); //updates.Add("l", new List<object>(new object[] { location.latitude, location.longitude })); keyRef.SetValueAsync(GeoLocationObjConverter.getInstance().toFireObj(geoHash.getGeoHashString(), location), geoHash.getGeoHashString()); }