Start a new topic

wikitude 1.2 and JSON Problem

wikitude 1.2 and JSON Problem


Hi,

have you tried debug your ARchitect World with Safari's web inspector?

Best regards

Andreas

Did not find the reason why the javascript part does not work.

The JSON does work and i could log all the values i overgive.

i m puzzled.

No idea why it stoped working with sdk 1.2 and 2.0.

Thanks for the answer Andreas.

It's a big help for me that i understand now that the JSON.parse is a built in function from webkits javascript engine.

But if i leave all the javascript the same and switch back to sdk1.1 it works. But on 1.2 and 2.0 the javascript part seems not to work anymore.

I trie to do more debugging now (it's not so easy in the javascript part).

Before the JSON parsing i have the radar stuff. Perhaps i overlooked some changed  there (i mena changes from the sdk11 to sdk12).

As soon i know more i will post it here. I You have any other idea why the javascript part stops working from 1.1 to 1.2 please let me know.

Here the javasript start part:

//++++++++Start and generates POIS and Buttons+++++++++++++++++++++++++++
            
            function createOnClickAnimation(imageDrawable) {
                var anim = new AR.PropertyAnimation( imageDrawable, 'scaling', 1.0, 1.2, 750, new AR.EasingCurve(AR.CONST.EASING_CURVE_TYPE.EASE_OUT_ELASTIC, {amplitude : 2.0}) );
                return anim;
            }
            
            function newData(jsonData,tmaxRange) {
                
                console.log("Start");

                AR.radar.background = new AR.ImageResource("radar.png");
                AR.radar.positionX = 0.02;
                AR.radar.positionY = 0.02;
                AR.radar.width = 0.15;
                AR.radar.centerX = 0.5;
                AR.radar.centerY = 0.5;
                AR.radar.radius = 0.4;
                //AR.radar.northIndicator.image = new AR.ImageResource("radarArrow.png");
                //AR.radar.northIndicator.radius = 0.4;
                AR.radar.onClick = function(){ AR.logger.info;};
                AR.radar.enabled = true;
                
                console.log("Radar Painted");
                
                jsonObject = JSON.parse(jsonData);
                
                console.log("Data loaded");
                //document.getElementById("statusElement").innerHTML='Loading JSON objects';    
                
                for(var i = 0; i < jsonObject.length; i++)
                {
                    console.log("loop: " + i);
                    var poidrawables = new Array();

                    if (jsonObject.name2.length>0) {
                        
                        var label = new AR.Label(jsonObject.name1,0.5, {offsetY : -1.4,
                                                 triggers: {
                                                 onClick:
                                                 createClickTrigger(i)},
                                                 style : {textColor : '#000000',backgroundColor : '#FFFFFF90'}});
                        var label2 = new AR.Label(jsonObject.name2,0.5, {offsetY : -1.9,
                                                  triggers: {
                                                  onClick:
                                                  createClickTrigger(i)},
                                                  style : {textColor : '#000000',backgroundColor : '#FFFFFF90'}});
                        poidrawables.push(label);
                        poidrawables.push(label2);
                        jsonObject.arLabel = label;
                        jsonObject.arLabel2 = label2;
                        jsonObject.labelCount = 2;
                        
                    } else {
                        var label = new AR.Label(jsonObject.name1,0.5, {offsetY : -1.4,
                                                 triggers: {
                                                 onClick:
                                                 createClickTrigger(i)},
                                                 style : {textColor : '#000000',backgroundColor : '#FFFFFF90'}});
                        poidrawables.push(label);
                        jsonObject.arLabel = label;
                        jsonObject.labelCount = 1;
                    }

                    var poiImage;
                    if (jsonObject.type <= maxType) {
                        poiImage = typeArray;
                        jsonObject.typeOn =true;
                    } else {
                        poiImage = typeArray;
                        jsonObject.typeOn =true;
                    }
                    
                    var img = new AR.ImageDrawable(poiImage, 2.0,
                                                {triggers: {
                                                onClick:
                                                createClickTrigger(i)}}
                                                );
                    
                    jsonObject.animation = createOnClickAnimation(img);
                    jsonObject.img = img;
                    
                    
                    poidrawables.push(img);
                    
                    geoLoc = new AR.GeoLocation(jsonObject.Point.latitude,jsonObject.Point.longitude,jsonObject.Point.altitude);
                    
                    var radarCircle = new AR.Circle(0.08, {style: {fillColor: '#468842'}});  //#83ff7b
                    var radarObject = new AR.GeoObject(geoLoc, {drawables: {cam: poidrawables, radar: radarCircle}});
                    jsonObject.radarCircle = radarCircle;
                    jsonObject.poiObj = radarObject;
                    
                }
                //document.getElementById("statusElement").innerHTML='JSON objects loaded';
                document.location = "architectsdk://architectViewReady";
                
            }

 

Hi Adrian,

Javascripts JSON.parse has nothing to do with the SBJSON framework on iOS. JSON.parse is a built in function from webkits javascript engine. If you have problems parsing the json string, please make sure that the string is a valid json and check if you pass the json as a string or object from objc to javascript. For example: If you have something like this in ObjC '@"newData('%@')"' where %@ will be replaces with your json fromatted ObjC string, then you need JSON.parse to get a json object in javascript. If you replace the ObjC call with '@"newData(%@)"', then you don't need JSON.parse in javascript because you're passing an json object into javascript.

Best regards

Andreas

Hello

OS 6.0.1, iPhone 4, Wikitude 1.2, Xcode 4.5.2

Wikitude 1.2 i not working for me.

I use in the javaScript part of Wikitude JSON (like the SimpleBrowserDemo).

jsonObject = JSON.parse(jsonData);

This part does not seems to work properly for me.

I realized that the JSON part was inside the lib of wikitude1.1 and is not there anymore in wikitude 1.2. Now you can use the -ObjC Flag in other linker flag. I did integrate the SBJSON classes that where in the Simple Browser Demo. But still it seem not to work.

I had a lot of problems because i had an other JSON Framework in my app (problems started with the -ObjC Flag that fixed the error with the linker signaturs in Xcode). Even if i removed it and had only SBJSON from the demo left, the same.

If i switch back to 1.1 it works fine (in this case i use the JSON from the lib and removed all JSON Frameworks and left only the JSON.h to get no errors).

What i do not understand: from where the javaScript gets the JSON Framework in wikitude1.2 if i do:

jsonObject = JSON.parse(jsonData);

?????

Any idea why the JSON does not work for me with wikitude 1.2 ????

Please help.

I tried for hours and days.

I'm a paying user.

Regards

Adrian
Login or Signup to post a comment