Start a new topic

POI From JSON file doesn't work

POI From JSON file doesn't work

Hi there,

I have been working on a WIKITUDE-Phonegap app. The application is a location based AR app that shows the markers on the camera view when tilting the phone arounnd (Displaying POI label) The license I have is Educational license so that the app I am developing doesn't have unlicensed watermark on it. 

The problem I am having now is that I want to use my own latitudes & longitudes and description of places instead of the random ones that app generates. I did everything following the Documentation about retrieving the data from JSON file. However, when I built it to the device, the markers won't appear. 

I am developing it on iOS 8.3 - Object-C based and test on iPhone 5.
Anyone has the same problem? How to solve this?

Any answers will be appreciated.
PS. excuse my English if you don't quite get what I tried to explain.

Thank you,
Scott

1 person likes this
Hi Scott,

could you please post your JSON file/data and the part where you load it.

Thank you and best regards,
Simon

PS. Your english sounds just fine to me! :-)
Hi Simon,

Thank you for your quick reply :) 

Here is my JSON file format look like.

var myJsonData = ;

Here is fromlocalresource.js code where I call the JSON data

// request POI data
requestDataFromLocal: function requestDataFromLocalFn(lat, lon) {
//var poisNearby = Helper.bringPlacesToUser(myJsonData, lat, lon);
//World.loadPoisFromJsonData(poisNearby);
/*
For demo purpose they are relocated randomly around the user using a 'Helper'-function.
Comment out previous 2 lines and use the following line > instead < to use static values 1:1.
*/
World.loadPoisFromJsonData(myJsonData);
}
};

/*var Helper = {

For demo purpose only, this method takes poi data and a center point (latitude, longitude) to relocate the given places randomly around the user

bringPlacesToUser: function bringPlacesToUserFn(poiData, latitude, longitude) {
for (var i = 0; i < poiData.length; i++) {
poiData.latitude = latitude + (Math.random() / 5 - 0.1);
poiData.longitude = longitude + (Math.random() / 5 - 0.1);
/* 

Note: setting altitude to '0' will cause places being shown below / above user,
depending on the user 's GPS signal altitude.
Using this contant will ignore any altitude information and always show the places on user-level altitude

poiData.altitude = AR.CONST.UNKNOWN_ALTITUDE;
}
return poiData;
}
}
*/

I have completely connected both files in index.html (in the ARChitect World subfolder called "5_ObtainPoiData_2_FromLocalResource")
I hope this is enough for the diagnosis. 

Thank you in advance,
Scott

Hi Scott,

ok I understand your problem better now. I tried your JSON Data with the same example you did, using the Helper function. All POIs did load just fine. 

Do you also see the POIs if you use the helper function? Could it be that you are just not close enough to the locations if you do not use the helper function?

Best regards,
Simon

1 person likes this
Hi Simon,

It works! OMG! You have no idea how many weeks I have been trying to fix this. You have just saved my life.

Thank you so much!

Anyway, there are 2 questions I would like to ask 

1.) How can I integrate JSON data into the "Presenting Details" POI and Add the radar? 
2.) can I change the Label to be HTML? I mean I read the documentation but I didn't quite get it. 

Thank you so much for your help.
Cheers,
Scott

Hi Scott,

I'm glad I could help you!

To your other questions:

1. Why not go the other way around? Use what you already have and add the details and radar. Check out the first two examples here http://www.wikitude.com/external/doc/documentation/latest/android/browsingpois.html#browsing-pois on how to do just that.

2. See http://www.wikitude.com/external/doc/documentation/4.1/Reference/JavaScript%20Reference/classes/HtmlDrawable.html for how to create a Html Drawable. Than instead of passing the label to the cam property of the GeoObject pass the HtmlDrawable.

Best regards,
Simon

hi Simon,

After trian and error, it works so well :) 

Thank you so much for your precious answers! I do appreciate them.

Cheers,

Scott 

when I find the question,I am very happy,because I do same modify as your code.Today, I use the helper function after seeing the answer,but it also doesn't work,I donn't what's wrong with the code.

Hi,

Please follow the exact steps provided in our documentation here https://www.wikitude.com/external/doc/documentation/latest/android/retrievingpoidata.html#from-a-local-resource. Also, make sure that your .json file is validated. In addition, you can try with our sample just to make sure that this is working for you and then modify the sample to fit your use case.

Thanks
Eva

 

Hi scott and simon,
I faced same problem as scott that POIs not displayed as per my json file. can you please tell me how you solve that problem? Share your file if possible.

 

Login or Signup to post a comment