Borys
Borys

Reputation: 1

Wikitude. Points of interest

I have problem with POI. After enter the world I can't see any point of interest.

Code in Android:

 @Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    buildGoogleApiClient();
    architectView.onPostCreate();
    try {
        this.architectView.setLocation(mLastLocation.getLatitude(),mLastLocation.getLongitude(),mLastLocation.getAltitude(),mLastLocation.getAccuracy());
        this.architectView.load( "file:///android_asset/demo2/index.html" );
    }
    catch (Exception e){
    }

HTML from my assets :

    <!-- MAIN PAGE CONTENT -->

    <!-- transparent footer-->
    <div data-role="footer" class="ui-bar" data-theme="f" data-position="fixed" style="text-align:center;">

        <!-- small status-button -->
        <a style="text-align:right;" id="popupInfoButton" href="#popupInfo" data-rel="popup" data-role="button" class="ui-icon-alt" data-inline="true" data-transition="pop" data-icon="alert" data-theme="e" data-iconpos="notext">Log</a> </p>

        <!-- popup displayed when button clicked -->
        <div data-role="popup" id="popupInfo" class="ui-content" data-theme="e" style="max-width:350px;">
          <p style="text-align:right;" id="status-message">Trying to find out where you are</p>
        </div>

    </div>

</div>

And here is the javascript code from example :

// implementation of AR-Experience (aka "World")
var World = {
   // true once data was fetched
   initiallyLoadedData: false,

   // POI-Marker asset
   markerDrawable_idle: null,

   // called to inject new POI data
   loadPoisFromJsonData: function loadPoisFromJsonDataFn(poiData) {

      /*
         The example Image Recognition already explained how images are loaded and displayed in the augmented reality view. This sample loads an AR.ImageResource when the World variable was defined. It will be reused for each marker that we will create afterwards.
      */
      World.markerDrawable_idle = new AR.ImageResource("assets/marker_idle.png");

      /*
         For creating the marker a new object AR.GeoObject will be created at the specified geolocation. An AR.GeoObject connects one or more AR.GeoLocations with multiple AR.Drawables. The AR.Drawables can be defined for multiple targets. A target can be the camera, the radar or a direction indicator. Both the radar and direction indicators will be covered in more detail in later examples.
      */
      var markerLocation = new AR.GeoLocation(poiData.latitude, poiData.longitude, poiData.altitude);
      var markerImageDrawable_idle = new AR.ImageDrawable(World.markerDrawable_idle, 2.5, {
         zOrder: 0,
         opacity: 1.0
      });

      // create GeoObject
      var markerObject = new AR.GeoObject(markerLocation, {
         drawables: {
            cam: [markerImageDrawable_idle]
         }
      });

      // Updates status message as a user feedback that everything was loaded properly.
      World.updateStatusMessage('1 place loaded');
   },

   // updates status message shon in small "i"-button aligned bottom center
   updateStatusMessage: function updateStatusMessageFn(message, isWarning) {

      var themeToUse = isWarning ? "e" : "c";
      var iconToUse = isWarning ? "alert" : "info";

      $("#status-message").html(message);
      $("#popupInfoButton").buttonMarkup({
         theme: themeToUse
      });
      $("#popupInfoButton").buttonMarkup({
         icon: iconToUse
      });
   },

   // location updates, fired every time you call architectView.setLocation() in native environment
   locationChanged: function locationChangedFn(lat, lon, alt, acc) {

      /*
         The custom function World.onLocationChanged checks with the flag World.initiallyLoadedData if the function was already called. With the first call of World.onLocationChanged an object that contains geo information will be created which will be later used to create a marker using the World.loadPoisFromJsonData function.
      */
      if (!World.initiallyLoadedData) {
         // creates a poi object with a random location near the user's location
         var poiData = {
            "id": 1,
            "longitude": (lon + (Math.random() / 5 - 0.1)),
            "latitude": (lat + (Math.random() / 5 - 0.1)),
            "altitude": 100.0
         };

         World.loadPoisFromJsonData(poiData);
         World.initiallyLoadedData = true;
      }
   },
};

/* 
   Set a custom function where location changes are forwarded to. There is also a possibility to set AR.context.onLocationChanged to null. In this case the function will not be called anymore and no further location updates will be received. 
*/
AR.context.onLocationChanged = World.locationChanged;

Before setting location to architectView I had message "Trying to find out where you are". Thanks for all responses.

Upvotes: 0

Views: 514

Answers (1)

Andreas Schacherbauer
Andreas Schacherbauer

Reputation: 243

Have you tried to call this.architectView.setLocation(mLastLocation.getLatitude(),mLastLocation.getLongitude(),mLastLocation.getAltitude(),mLastLocation.getAccuracy()); after this.architectView.load( "file:///android_asset/demo2/index.html" );? You can also implement the ArchitectView.ArchitectWorldLoadedListener class to inject the location once the web view finished loading the .html.

Upvotes: 0

Related Questions