Start a new topic

JSon data WikitudeSDK + PhoneGap

JSon data WikitudeSDK + PhoneGap


I am trying to display markers from a remote JSON file.

using this as example 





* This function gets called it the Wikitude SDK is able to start an ARchitect World (the current device is supported by the Wikitude SDK)



    onDeviceIsReadyCallback : function()


        // The device is able to launch ARchitect World, so we load the 'Hello World' example



        // To be able to respond on events inside the ARchitect World, we set a onURLInvoke callback



var sURL = "";



    tags: "jquery",

    tagmode: "any",

    format: "json"


  function(data) {

    $.each(data.items, function(i,item){

      WikitudePlugin.callJavaScript("didReceivedNewTextForLabel('" + + "')");

      return false;





the application is not able to let me connect to the JSON file, while the same code works from the browser, but for some reason I am not able to dowload the data

could you please help me to fix this issue?


Thanks a mil.

Hi there!

I guess you want to display a number of POIs in the camera.
The "Hello World" Sample in our PhoneGap github-sample should only point out how you can interact with one "AR.Label" in ARchitect.

In your case you want to inject a number of POIs and display them as so called "AR.GeoObjects". Interaction and setup is quite similar. Please have a look at the SimpleARBrowser sample in the you downloaded from

Keep in mind that all the HTML/ARchitect world samples work on phoneGap same way than in any WikitudeSDK. You develop the ARchitect experience once and can display it using the iOS/Android/BB SDK or PhoneGap

Hope that helps.



I am starting using your SDK, I have downloaded the "HelloWorld" example I have renamed the newData(jsonData) method with jsonpdataPOI(jsonData)

I Need to be able to download data directly from the HelloWorld.hml

You will see in highlighted in yellow the extra code that I have added on "HelloWorld" page.

the AR.context.onLocationChanged = locationChanged; looks like not being called, then the data non downloaded

Could you please help me to sort this?



 ---->  myGeoLocation = null;



            //function called from the native app fia callJavascript method

            //receives json-data as string and processes the contained information

            function jsonpdataPOI(jsonData){

                jsonObject = jsonData;

                document.getElementById("statusElement").innerHTML='Loading JSON objects';



                for(var i = 0; i < jsonObject.length; i++)


                    var poidrawables = new Array();

                    var label = new AR.Label(,1.0, {offsetY : -1.5,

                                             triggers: { 



                                             style : {textColor : '#FFC100',backgroundColor : '#FFFFFF80'}});


                    jsonObject.arLabel = label;


                    var poiImage;


                    if( == 1) 


                        poiImage = firstImage;


                    else if( == 2)


                        poiImage = secondImage;


else if( == 3)


                        poiImage = thirdImage;




                        poiImage = forthImage;




                    var img = new AR.ImageDrawable(poiImage, 2.0,

                                                   {triggers: { 





                    jsonObject.animation = createOnClickAnimation(img);

                    jsonObject.img = img;




                    //geoLoc = new AR.GeoLocation(jsonObject.Point.latitude,jsonObject.Point.longitude,jsonObject.Point.altitude);

                    geoLoc = new AR.GeoLocation(,jsonObject.lng,jsonObject.alt);

                    jsonObject.poiObj = new AR.GeoObject(geoLoc, {drawables: {cam: poidrawables}});



                document.getElementById("statusElement").style.display = "none";





function locationChanged(lat, lon, alt, acc) {

            document.getElementById("statusElement").innerHTML='GPS Locations';

            // We are only interested in the first location, let's set the onLocationChanged trigger to null which

            // will deactivate it.

            AR.context.onLocationChanged = null;


            // Add a random value to current location, placing it randomly in the user's vicinity

            var objLat = lat + ((Math.random() - 0.5) / 1000);

            var objLon = lon + ((Math.random() - 0.5) / 1000);


            // Create a new GeoLocation with the calculated latitude and longitude

            // A GeoLocation defines a geo refernece location using latitude and longitude.  

            myGeoLocation = new AR.GeoLocation(objLat,objLon);


            // loading step is done, check if we need to start the experience

            document.getElementById("statusElement").innerHTML='Downloading data...';

            if (myGeoLocation != null && image.isLoaded()) {


           var surl =  ""; 


               url: surl, 

               data: { 


                       lat: "53.277096", //lat, //

                       lng: "-6.414857", //lon, //

                       rad: "100",

                      dataType: "jsonp"


             dataType: "jsonp",

             jsonp : "callback",

             jsonpCallback: "jsonpdata",

             crossDomain: true });






// Set the on location changed trigger to call 'locationChanged'

AR.context.onLocationChanged = locationChanged;

Hi there!

You're making good progress. Looks good so far.
Quite hard to see the mistake/error without having the full sample in place.

Anyway: I recommend you to reach the goal step-by-step.

Import ade.js in oyur World's html as described in the ADE.html in the ArchitectTools Folder of the SDK (<script type="text/javascript" src="ade.js"></script>)

Having ade.js imported you can open the world on your dektop PC's browser and use JS Debugging tools, browser plugins or simply use the Inspect Element/JS Console feature of your preferred browser

Assure your JSON requests work as expected by adding the equest-command to the "onDeviceIsReadyCallback"-function and to some logging output there

Check if SIM is in your device (some Android ROM's do not fire location updates without SIM inserted) or use LocationSpoofer app for Android

The ade.js is something really helpfull - You can develop way faster since errors and debug information is provided. (You may write "AR.logger.debug("yourMessage");" and see it in the logging console.

Hope that helps.

Login or Signup to post a comment