Hi , I have put distance to user information in a label to show to the user . it shows correctly when the ARchitect world launches . but the problem is it doens't update as the user moves . here's the multiplepois.js and marker.js files which I have modified , I call marker function in onLocationChanged function so I think it should update correctly.
multiplepois.js :
var World = {
markerDrawable_idle1: new AR.ImageResource("assets/marker_idle1.png"),
markerDrawable_idle2: new AR.ImageResource("assets/marker_idle2.png"),
markerDrawable_directionIndicator: new AR.ImageResource("assets/indi.png"),
// New: a array holding a reference to all marker objects
this.distanceLabel = new AR.Label(disLocationString , 0.7, {
zOrder : 1,
offsetX: 0.7,
scale : 0.5,
style: {
textColor : '#FFFFFF'
}
});
var markerObject = new AR.GeoObject(markerLocation, {
drawables: {
cam: ,
indicator: this.directionIndicatorDrawable,
radar: this.radardrawables
}
I'll apprecaite if you can help me with this , everything seems right but it doens't update as the user moves .
thanks
W
Wolfgang Damm
said
about 10 years ago
You are setting the AR.context.onLocationChanged trigger to null when it is called the first time. Therefore it won't be called again and you will have no possibility to update the labels.
Even if this is not done, your code will create new markers each time the location is updated. Thus there need to be a additional logic to update distance labels.
e.g.
define a new function that is set as the onLocationChanged trigger after it was called the first time. Within this function recalculate the distance and update the labels with the new values: distanceLabel.text = newdistance;
Let me know if you have further questions.
m
m0j1 42420
said
about 10 years ago
Thanks Wolfgang, I did it as you said by commenting out AR.context.onLocationChanged = null; and by defining a boolean variable to check if it's first time and in the first time I created poi objects. after that I did this to update the distance label of pois :
var newLocation = new AR.GeoLocation(latitude, longitude, altitude);
var distanceUpdate = newLocation.distanceToUser();
for(i=0;i<World.markerList.length;i++)
{
var newLocation2 = World.markerList.locationHolder;
var distanceUpdate2 = newLocation2.distanceToUser();
m0j1 42420