Wikitude
play_for_work
Forum
FAQ
Documentation
Download
wikitude.com
How can we help you today?
Enter your search term here...
Search
Start a new topic
Discussions
Wikitude SDK (Android, iOS, UWP)
Wikitude SDK Questions or Problems
Updating POI distance
L
Luca
started a topic
about 9 years ago
Updating POI distance
3 Comments
Oldest First
Popular
Newest First
Sorted by
Oldest First
L
Luca
said
about 9 years ago
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;
}
L
Luca
said
about 9 years ago
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;
}
E
Eltos Riel Ramos
said
over 7 years ago
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 :)
Login
or
Signup
to post a comment
More topics in
Wikitude SDK Questions or Problems
Instatiation of WTArchitectView compile errors
Point of interest - native iOS
Slider
Camera lagging / slow in native Swift application
Create a web service
N-th ImageDrawable not displayed
Radar Example
stop defaultlocationmanager and use architectview.injectlocation ios 10
WTC Size Limit
AngularJS and wikitude
See all 3869 topics
© 2021 Wikitude, a Qualcomm company
Luca