Start a new topic

Updating POI while moving [Google Glass]

Updating POI while moving [Google Glass]


Hi,
I am using WIkitude for Google Glass. I am showing POIs using wikitude AR SDK.However i am getting POIs locations from WebService and drawing in Camera Surface(ArchitectVIew). My problem is that how can i update POIs? I want that while i am moving if i am passing x meters, i want to send again a request to WebService and get new Locations and redraw them? Is this possible? If so how to achive it?

I am getting Locations of POIs and sending them for drawing:

for (PoiModel pointsOfInterest : sliced) {
HashMap<String, String> poi = new HashMap<String, String>();

poi.put("lat",String.valueOf(pointsOfInterest.lng));
poi.put("lng", String.valueOf(pointsOfInterest.lat));
poi.put("foo", pointsOfInterest.foo);

pois.put(new JSONObject(poi));
}

Now i will use requestLocationUpdates to request new data from webservice from onLocationCh:
What are the next steps i should do so i refresh POIs on ArchitectView (Redraw new ones on new locations) ?

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, Constants.MIN_DISTANCE_UPDATE, this);

 

Hi there!

Summarizing your scenario:

* You already implemented location changes in your GoogleGlass native application - this also means that you will get notified in JS environment about any location changes (implement AR.context.onLocationChanged)
(For more precise location handling have a look at Location Strategy approaches)

* You want to load POI data every x-meters and replace the existing ones - There is a powerful method named AR.context.destroyAll(), which deletes everything inside the AR scenery. I recommend to manage laoding of POI data in JavaScript and manage deletion of old and creation of the new ones also in JavaScript.

* Have a look at the crosshair forum post in case you want to implement a handsfree autoselect

Hope that helps,

Kind regards,
Andreas

Thnx Andreas.

The thing is that i have to make a request to WebService on Location Change and then show the new response. Where should i call destroyAll()? In Javascript or Java? Is it possible that i get new data and then send them to Javascript, destroy old ones and create new ones? Do you have any small example regarding to that?

I am trying smth like:
 

// location updates, fired every time you call architectView.setLocation() in native environment
locationChanged: function locationChangedFn(lat, lon, alt, acc) {
World.log("location received > "+lat+":"+lon);


var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", "myUrl", false );
xmlHttp.send( null );

World.log("location on change:" + xmlHttp.responseText);

if (!World.initiallyLoadedData) {
var poiData = {
"lat": parseFloat(poiData.lat),
"lng": parseFloat(poiData.lng),
"poiName": poiData.poiName,
};
World.loadPoisFromJsonData(poiData);
World.initiallyLoadedData = true;
}



AR.context.destroyAll();

 

World.markerList.push(new Marker(singlePoi));
},

 

Hi again!

Just keep in mind that the clean way is to call ".destroy()" of all used components since the AR.context.destroyAll() wipes away the whole scene, including e.g. compass assets.
Anyway: The fastest approach would be to recreate whole scene after x meters calling AR.context.destroyAll() as a first statement, right before creation of new POIs happens (in your code you create new POIs and wipe them away right afterwards).

Also ensure to have a smart mechanism in place for reloading POIs every >50m - otherwise the app may constantly request new data because of possibly inaccurate GPS signals.

Kind regards


As the

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

is fired whenever we call architectView.setLocation, i tied doing all networking work on Java and after getting new data call architectView.setLocation(). But this reloads all the view and redraws the POIs. How can i avoid reloading(redrawing) all the view instead of just redrawing POIs?

Hi again,

As written in my last post, you may either call .destroy() on all existing POI assets (hold an instance of them and call destroy of each POI)  and create the new ones accordingly or use overall AR.context.destroyAll() to wipe away all assets from the scene.

Kind regards

Well as i said, should i just call it inside

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

 

I mean does this function triggers automatically, or we have to trigger using .setLocation();

you have to setLocation in native environment manually. Any of those native calls then results in a JavaScript callback execution of AR.context.onLocationChanged automatically.

I managed to do that, but the thing is that it closes the View and it reopens it. It doesnt destroyAll() and add new ones in real time. Is it possible i remove pois and add the new ones i got from service In REAL TIME?
 

Unfortunately deletion and creation takes some time, depending on your device performance, even a second.
Reason for that is usually, that the resources required need to be loaded first. That's why the proper "destroy what you no longer need" approach works better than the "destroy to reset".
You may even check first which POIs are no longer needed, destroy ony those, and create the new ones only, which will improve app performance a lot.

In addition you may display a short spinning wheel to indicate that something is changing in the UI.
Login or Signup to post a comment