Start a new topic

How do I put my custom GPS coordinates in this?


te
favorite

I am new and am using Wikitude SDK for Android (An AR application) and they currently have the markers randomly being set.

   /* Location updates, fired every time you call architectView.setLocation() in native environment. */
locationChanged: function locationChangedFn(lat, lon, alt, acc) {

    /*
        The custom function World.onLocationChanged checks with the flag World.initiallyLoadedData if the
        function was already called. With the first call of World.onLocationChanged an object that contains geo
        information will be created which will be later used to create a marker using the
        World.loadPoisFromJsonData function.
    */
    if (!World.initiallyLoadedData) {
        /* Creates a poi object with a random location near the user's location. */
        var poiData = {
            "id": 1,
            "longitude": (lon + (Math.random() / 5 - 0.1)),
            "latitude": (lat + (Math.random() / 5 - 0.1)),
            "altitude": 100.0
        };

        World.loadPoisFromJsonData(poiData);
        World.initiallyLoadedData = true;
    }
}

I have tried simply replacing the math portion with coordinates like this

        "longitude": (lon + (-80.624594)),
        "latitude": (lat + (40.366950)),

That doesn't work or

        "longitude": (-80.624594),
        "latitude": (40.366950),

or

        "longitude": (lon = -80.624594),
        "latitude": (lat = 40.366950),

But to no avail. Any help/tips would be appreciated.

Thanks


Hi,



I would imagine versions 1 and 2 to work, version 3 seems to me to be incorrect syntax, but since it's JavaScript, who knows...


Version 1 will add several thousand kilometers to the current GPS location of the device in both latitude and longitude and, potentially, push it out of the valid ranges ([-90, 90] for latitude, [-180, 180] for longitude).


Version 2 refers to a geolocation somewhere in western China. Is this really where you intended to place your maker?



- Daniel

Hi Daniel, Thank you for the response. I am not quite sure where you are getting Western China from. It is supposed to be a neighborhood in North Eastern Ohio. If you type in "40.366950, -80.624594" into Google it shows you exactly that. Is the Lat and lon switched?

image


Update: With Version 2, it shows it on the ground and not at my height and where ever I go it sticks to the ground no matter what direction I am facing...

Hi Francis,



sorry for the confusion with the location. Must have been a copy&paste fail on my end. I'm now getting Ohio as well. So all go there. Did you set an altitude for your GPS location or just latitude and longitude?


Would it be possible for you to make a short screen recording of what's happening? Does the Marker move at all? Rotate?



- Daniel


I actually got it to work by using the Local Resource sample with the static JSON data. The only thing now is that no matter where I am, the POI constantly rotate around me. I have tried it outdoors and stayed away from metal and whatnot. I have also added the Google Play services to my build.gradle file. Is there a particular function that deals with this that I do not know about? I saw this error in another forum post but it was unsolved...

Login or Signup to post a comment