Finding JSON Data using geoquery gives error

0 votes

When using the code given in http://api.shephertz.com/tutorial/Querying-Your-App-Data/?index=query-appdata#fetching_json_data_using_geo_query, it gives an error in mismatch type of arguments as findDocumentsbyQuery cannot be used with geoquery. Please help.

asked Mar 4, 2016 in Android by 12bce071 (10 points)

1 Answer

0 votes

Hi,

 

Please find below code snippet to fetch document based on geo query and let me know if it helps:


	
String dbName = "<Your_DataBase_Name>";
String collectionName = "<Your_Collection_Name>"; 
GeoTag gp = new GeoTag();
gp.SetLat(-73.99171);
gp.SetLng(40.738868);
storageService.SetGeoTag(gp);
GeoQuery query = QueryBuilder.BuildGeoQuery(gp, GeoOperator.NEAR, new BigDecimal(100));
App42Log.SetDebug(true);		//Print output in your editor console
App42API.Initialize("API_KEY","SECRET_KEY");
StorageService storageService = App42API.BuildStorageService(); 
storageService.FindDocumentsByLocation(dbName, collectionName, query, new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		Storage storage = (Storage) response;
		IList<Storage.JSONDocument> jsonDocList = storage.GetJsonDocList(); 
		for(int i=0;i <jsonDocList.Count;i++)
		{   
			App42Log.Console("objectId is " + jsonDocList[i].GetDocId());
			App42Log.Console("jsonDoc is " + jsonDocList[i].GetJsonDoc());
		}  
	}

	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}

 

 
Regards,
Himanshu Sharma
answered Mar 4, 2016 by hs00105 (2,005 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...