Start a new topic

Updating POI distance

Updating POI distance


hello, i read about your solution and i want to ask where did you put your for loop?? in the marker.js or in nativedetailscreen.js??

i hope you can reply to this :)

I solved doing this (setting markerLocation var as a property of Marker object)

 

for(i=0;i< World.markerList.length;i++)

            {

                var newLocation2 = World.markerList.markerLocation;

                var distanceUpdate2 = (newLocation2.distanceToUser() > 999) ? ((newLocation2.distanceToUser() / 1000).toFixed(2) + " km") :     (Math.round(newLocation2.distanceToUser()) + " m");

                World.markerList.descriptionLabel.text = distanceUpdate2;

}

Hello,

I'm trying to update poi's distance but all the things I tried, didn't work...

Using the Multiple POI's sample, I modified it as below: 

 

// location updates, fired every time you call architectView.setLocation() in native environment

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

 

        

// request data if not already present

if (!World.initiallyLoadedData) {

World.requestDataFromLocal(lat, lon);

World.initiallyLoadedData = true;

}

        else

        {

            while(AR.GeoObject)

            {

                document.getElementById("page1").innerHTML = ""+Math.random();

                AR.GeoObject.destroy();

            }

            document.getElementById("page1").innerHTML = " & "+Math.random();

            World.requestDataFromLocal(lat, lon);

        }

}

 

 

The innerHTML is only a test.

App destroys all the GeoObject, but when it recreates the objects distance is not updated.

Distance is set in marker.js file, as below

 

function Marker(poiData) {

 

    this.poiData = poiData;

 

    var markerLocation = new AR.GeoLocation(poiData.latitude, poiData.longitude, poiData.altitude);

    var distance = (markerLocation.distanceToUser() > 999) ? ((markerLocation.distanceToUser() / 1000).toFixed(2) + " km") : (Math.round(markerLocation.distanceToUser()) + " m");

    this.markerDrawable_idle = new AR.ImageDrawable(World.markerDrawable_idle, 2.5, {

        zOrder: 0,

        opacity: 1.0,

        onClick: Marker.prototype.getOnClickTrigger(this)

    });

 

    this.markerDrawable_selected = new AR.ImageDrawable(World.markerDrawable_selected, 2.5, {

        zOrder: 0,

        opacity: 0.0,

        onClick: null

    });

 

    this.titleLabel = new AR.Label(poiData.title.trunc(10), 1, {

        zOrder: 1,

        offsetY: 0.55,

        style: {

            textColor: '#FFFFFF',

            fontStyle: AR.CONST.FONT_STYLE.BOLD

        }

    });

 

    this.descriptionLabel = new AR.Label(distance, 0.8, {

        zOrder: 1,

        offsetY: -0.55,

        style: {

            textColor: '#FFFFFF'

        }

    });

 

    // Changed: 

    this.markerObject = new AR.GeoObject(markerLocation, {

        drawables: {

            cam:

        }

    });

 

    return this;

}

 
Login or Signup to post a comment