Start a new topic

Problem with object use geo location

I use to Wikitude SDK Javascript

I have used GeoLocation show object represents a location in the earth's three-dimensional space. The Object has been displayed but when I move the camera, the object also is moved follow. I don't know why?

 

code here:

var locationSun = new AR.GeoLocation(20.9757, 105.8397,10);

        var sunImg = new AR.ImageResource("assets/Sun-icon.png");
        var indicatorImg = new AR.ImageResource("assets/indi.png");

        var sunSize = 3;

        var sun = {
            name: "Truesure",
            distance: 0,
            location: locationSun,
            imgDrawable: new AR.ImageDrawable(sunImg, sunSize),
            size: sunSize,
            description: "The Sun is the star at the center of the Solar System. It is almost perfectly spherical and consists of hot plasma interwoven with magnetic fields.",
            mass: "2&nbsp;10<sup>30</sup>&nbsp;kg",
            diameter: "1,392,684&nbsp;km"
        };

        /* put sun, planets (and pluto) in an array */
        this.planetsInfo = [sun];

        /* create helper array to create goeObjects out of given information */
        var planetsGeoObjects = [];
        for (var i = 0; i < this.planetsInfo.length; i++) {

            /* show name of object below*/
            var label = new AR.Label(this.planetsInfo[i].name, 0.3, {
                offsetY: -this.planetsInfo[i].size / 2,
                verticalAnchor: AR.CONST.VERTICAL_ANCHOR.TOP,
                opacity: 0.9,
                zOrder: 1,
                style: {
                    textColor: '#FFFFFF',
                    backgroundColor: '#00000005'
                }
            });

            /* drawable in cam of object -> image and label */
            var drawables = [];
            drawables[0] = this.planetsInfo[i].imgDrawable;
            drawables[1] = label;

            /* Create objects in AR*/
            planetsGeoObjects[i] = new AR.GeoObject(this.planetsInfo[i].location, {
                drawables: {
                    cam: drawables
                },
                onClick: this.planetClicked(this.planetsInfo[i])
            });

        }

        // Add indicator to sun
        var imageDrawable = new AR.ImageDrawable(indicatorImg, 0.1, {
            verticalAnchor: AR.CONST.VERTICAL_ANCHOR.TOP
        });
        planetsGeoObjects[0].drawables.addIndicatorDrawable(imageDrawable);
    },

 

https://youtu.be/bP7gPc7TFxQ


Hello Vu,

Please refer to this tutorial 'How to work with GeoLocation Class' to see if the information provided there help with your issue.

Thanks
Eva

 


1 person likes this

thank you very much. 


sorry, but I have added one question

example var location = new AR.GeoLocation(47.805634, 13.045209);
when I allocate variable location with  GeoLocation. I see that the Object Earth is no fix position, the position of its has moved change. please see link youtube
https://youtu.be/rEWT1qhEjpE

 why has position of its changed?

Hello Vu,

Please refer again to the tutorial I have placed in the forum post above. There, it explicitly says that

When you are testing GeoLocation features, you need to keep in mind that the results could be greatly influenced by these two factors:
  • Testing inside. This could deteriorate the performance and therefore, it is always advisable to test outside. GPS provider.
  • You need to make sure that the GPS provider you are using is accurate enough and it does not influence the performance. So, if you are testing with an old device then this could influence the results.

Thanks

Eva


Login or Signup to post a comment