2015-11-09 1 views
0

J'ai créé un projet Android Studio et importé l'exemple Wikitude (Wikitude SDK 5.0) dans le dossier assets. Je suis nouveau dans JavaScript et Wikitude, mais je pense que je suis capable d'obtenir les coordonnées GPS, mais aucun POI n'apparaît.Wikitude POI n'apparaîtra pas sur Android

L'un de vous a-t-il une expérience avec Wikitude sur Android? Comment puis-je faire apparaître le POI? La documentation officielle ne va pas aider. !

Désolé pour le long code source, mais je suis coincé pendant 2 jours maintenant et ne peut pas comprendre une bonne solution :(Votre aide est appréciée

POILOCATION.js:

// 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'); 
}, 

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) { 
    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; 
AR.context.onLocationChanged = locationChangedFn(lat, lon, alt, acc) { 
    console.log("asdsadasdsadasasdadaello World"); 

           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.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'); 
     World.initiallyLoadedData = true; 
}}; 

Répondre

3

Ok, j'ai trouvé la solution: après avoir mis en place une mise à jour de localisation GPS comme normal dans Android, j'ai oublié d'ajouter la ligne "architectView.setLocation":

private void makeUseOfNewLocation(Location location) { 
    try { 
     architectView.setLocation(location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getAccuracy()); 
     this.architectView.load("poi_1/index.html"); 
    } catch (IOException e) { 
     e.printStackTrace(); 
    } 
} 

maintenant, everyt hing fonctionne parfaitement.

+0

Salut, j'ai le même problème, l'application me donne juste un message "essayant de trouver où vous êtes". Je suis en train de lancer l'application exemple appelée poiatlocation, sans aucun changement. Puis-je demander où vous avez ajouté le morceau de code ci-dessus? –