首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Wikitude不会出现在Android上

Wikitude不会出现在Android上
EN

Stack Overflow用户
提问于 2015-11-09 16:23:37
回答 1查看 1.1K关注 0票数 0

我创建了一个Android项目,并将Wikitude示例(WikiteSDK5.0)导入到资产文件夹中。我是JavaScript和Wikitude的新手,但我想我可以得到GPS的和弦,但没有POI出现。

你们中有谁有过在Android上使用Wikitude的经验吗?我怎样才能使POI出现?官方文件帮不上忙。

很抱歉使用了很长的源代码,但是我现在被困了两天了,无法找到任何好的解决方案:(感谢您的帮助!)

POILOCATION.js:

代码语言:javascript
复制
// 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;
}};
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-10 10:27:21

好的,我找到了解决方案:当我在Android中正常设置GPS位置更新后,我忘记添加"architectView.setLocation“行:

代码语言:javascript
复制
    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();
    }
}

现在,一切都很完美。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33613580

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档