Start a new topic
Solved

Constantly update POI information based on data from the native code?

Hello! I am completely new to JavaScript and HTML but am considering Wikitude for developing an Android AR app for the ODG R-7 smartglasses. Before I invest my very limited time in learning JavaScript, I want to be as certain as possible that what I need to do can be implemented using Wikitude. My application needs to do the following:


  • Information about a moving target is displayed as text on a POI. The location and information about this target is changing.
  • The information, including the GPS coordinates, is received from another program in the native code. Therefore, it should be possible to pass this information to the JavaScript code and update the location and the text that is attached to the target POI each time the information message is received.


Based on what I’ve read in these forums I conclude that it’s possible to forward information from the native code the javascript code. What I am worried about is updating the location of the POI and the text that is shown. Do you think both of these are possible? Maybe labels could be used to present this changing information? Or could HTMLdrawables also be used in this manner, to present data that is changed constantly? Can other things besides labels and HTMLdrawables be used to attach text on a POI?


Thank you so much for your help!


Hi Janna,


I would recommend to start with 7.1 as it should be very stable already and it contains mostly bugfixes.


Best Regards,

Alex

Great, thank you so much! One more question: would you recommend starting out with 7.0. or 7.1.?

Hi Janna,

You can add and call any function you want, you just have to make sure that the signature of the JS method matches what you use as argument for architectView.callJavascript.  When you call those methods is up to you.

For the second question:
You can change the html code of the HTMLDrawable by using the html property. e.g.:

 

//create a new html drawable and pass some setup parameters to it
var htmlDrawable = new AR.HtmlDrawable({html:"<div>My div</div>"}, 1, {
  translate : { x: 1 },
  onClick : function() {
    htmlDrawable.html += "<div>Another div</div>"; // change the html
  },
  horizontalAnchor : AR.CONST.HORIZONTAL_ANCHOR.LEFT,
  opacity : 0.9
});

 

Best Regards,

Alex

Wow, that was fast! The example code was very nice. I have some additional questions:

  • So it would be possible to add some event function like onLocationChanged but onInformationReceived (or something like that) which would trigger forwarding of the information to the JavaScript code? All the information needs to be updated even if the location stays the same.
  • Can the elements of the HMTLdrawable be updated by a function that is triggered in this manner?


Thanks again!

Hi Janna,


what you are describing is possible with the Wikitude ODG SDK.


I recommend you take a look at the current dev-release sample app(Beta) because we refactored the sample app with 7.1. to make it more clear. In the "advanced" package you will find the PoiDataFromApplicationModelExtension this is the Java counterpart to the AR-Experience in assets/samples/09_ObtainPoiData_1_FromApplicationModel. This sample is using the connection from Java to JS to generate POIs.


To display text there are no options other than the Label or HTMLDrawable.


Best Regards,

Alex



Login or Signup to post a comment