Start a new topic

How can i get altitude to work?

How can i get altitude to work?


the included example is a very simple one. But you are right that the POIBean should have an altitude property. The reason it works is that a GeoLocation's altitude parameter is optional on construction. It will be assigned the CONST.ALTITUDE_UNKOWN value to mark the altitude as unkown.

We'll update the sample for the next SDK bugfix release. Thanks for letting us know.


Hi all,

Iam just stared out with the Wikitude framwork for Android. Just trying the exemple that came with the SDK for Andriod.
I cant understund how i set altitude for a POI. If we look into the loadSampleWorld method, the PoiBean does not have any property for altitude? why not?

 private void loadSampleWorld() throws IOException {
  this.architectView.load("tutorial1.html");  JSONArray array = new JSONArray();
  poiBeanList = new ArrayList();
  try {
   for (int i = 0; i     double location = createRandLocation();
    PoiBean bean = new PoiBean(
      "Probably one of the best POIs you have ever seen. This is the description of Poi #"
        + i, 4, location, location);
  this.architectView.callJavascript("newData('" + array.toString() + "');");
  } catch (JSONException e) {
   // TODO Auto-generated catch block
But if you look in the javascript that is called by this method the new AR.GeoLocation takes a altitude parameter, guess thats always is null or something then?

How can i get altitude to work?     //function called from the native app fia callJavascript method
            //receives json-data as string and processes the contained information
            function newData(jsonData){
                jsonObject = JSON.parse(jsonData);
                document.getElementById("statusElement").innerHTML='Loading JSON objects';
                for(var i = 0; 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(jsonObject.type == 1)
                        poiImage = firstImage;
                    else if(jsonObject.type == 2)
                        poiImage = secondImage;
                     else if(jsonObject.type == 3)
                        poiImage = thirdImage;
                     poiImage = fourthImage;
                    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);
                 jsonObject.poiObj = new AR.GeoObject(geoLoc, {drawables: {cam: poidrawables}});
Hope someone can point me in the right direction here :)


Thanks for your answer. Iam happy to help!

To get the altitude to work with the sample code, i just assasin a value to altitude in the GeoLocation constructor? Or is it any other stuff i need to do to get the POIs to render on diffrent langitude, latitude and altitudes?
geoLoc = new AR.GeoLocation(jsonObject.Point.latitude,jsonObject.Point.longitude,jsonObject.Point.altitude)

Additionally you would need to put the altitude into the JSON transfered from your native Android app via callJavascript. Thus adding  an altitude field to POIBean would be required.

As for the Javascript side: just be sure to use jsonObject.Point.altitude (with ), otherwise the code is correct.
Thanks i have added the property to the PoiBean and the JSON transfered to javascript holds diffrent altitude values for each POI but they render in a straight line on the screen. Any idea?

Is there some kind of settings to ignore altitude in the application that are set as default?

Alitude will only be used for displaying the points if the location comes from GPS with enough accuracy. You can check the accuracy value passed to AR.context.onLocationChanged to see if it is of high accuracy.

Is it possible to set a relative altitude? Es 5mt under the horizon (-5.0)?

Please have a look at

it is basically about the same topic.
Login or Signup to post a comment