我有POI的问题。进入这个世界后,我无法看到任何兴趣点。
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:
<!-- 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>
这是来自示例的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');
},
// 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;
在将位置设置为architectView之前,我有消息&#34;试图找出你的位置&#34;。 感谢所有回复。
答案 0 :(得分:0)
您是否尝试在this.architectView.setLocation(mLastLocation.getLatitude(),mLastLocation.getLongitude(),mLastLocation.getAltitude(),mLastLocation.getAccuracy());
之后致电this.architectView.load( "file:///android_asset/demo2/index.html" );
?一旦Web视图加载完.html,您还可以实现ArchitectView.ArchitectWorldLoadedListener
类来注入位置。