Start a new topic

problems trying mixing samples code

problems trying mixing samples code


Hi, i downloaded the latest SDK, configuring good everything with macOSx and Android SDK, and succesfully testing single samples code into my GNexus.

 

I'm coding a geolocalization guide with PhoneGap and i want to add some augumented reality options into it. I'm trying to mixing code of the examples, but  some functions seem doesn't works properly.

 

I edit the "4_Obtain$Poi$Data_2_From$Local$Resource" example to showing my POI in the JSON file and it works. Here is the first question:

 

1) everytime i run the app, the POI have different positions and i didn't understand why. My position in my office is always the same but the POI changes location. I tried to comment the line "var poisNearby = Helper.bringPlacesToUser(myJsonData, World.userLocation);" but when i run the app, the JSON didn't load properly.

 

 

Another question is: 

2) I wanted to add a description when the POI are clicked (like the 5.1 example). I added that lines of code "onMarkerSelected: "function onMarkerSelectedFn(marker) {

 

// notify native environment

document.location = "architectsdk://markerselected?id=" + marker.poiData.id;"

}" at the end of the "locationChanged: function locationChangedFn(lat, lon, alt, acc)" in the file "poisFromLocal.js", compile, run the app,  but it doesn't work. 

 

Where i'm making mistakes?

 

Kind regards

Brus

 

ps if needed i wil upload the files i have edited.

Hi Brus,

Please find answers inline

1) everytime i run the app, the POI have different positions and i didn't understand why. My position in my office is always the same but the POI changes location. I tried to comment the line "var poisNearby = Helper.bringPlacesToUser(myJsonData, World.userLocation);" but when i run the app, the JSON didn't load properly.

 

Reply: Did you also change the next line to World.loadPoisFromJsonData(myJsonData); ?
Otherwise poisNearby is undefined

 

Another question is: 

2) I wanted to add a description when the POI are clicked (like the 5.1 example). I added that lines of code "onMarkerSelected: "function onMarkerSelectedFn(marker) {

 

// notify native environment

document.location = "architectsdk://markerselected?id=" + marker.poiData.id;"

}" at the end of the "locationChanged: function locationChangedFn(lat, lon, alt, acc)" in the file "poisFromLocal.js", compile, run the app,  but it doesn't work. 

 

Reply: You have to check marker.js implementation too "Marker.prototype.getOnClickTrigger" and add World.onMarkerSelected(marker); , besides that you need to handle these events also in native implementation as in Sample 5.1.

 

Hope that helps.
Regards,
Andreas

Hi Andreas, thanks for your kind reply.

I reply as you did, in line:

 

1)Did you also change the next line to World.loadPoisFromJsonData(myJsonData); ? Otherwise poisNearby is undefined

Yes i did, i edit the line like that: "World.loadPoisFromJsonData(myJsonData);" and i commented the  "var Helper" and "bringPlacesToUser:" function also, but it still continue to set "random" position to my POI everytime i run the sample.

 

2) You have to check marker.js implementation too "Marker.prototype.getOnClickTrigger" and add World.onMarkerSelected(marker); , besides that you need to handle these events also in native implementation as in Sample 5.1.

 

I tried to edit the "marker.js" of 4.2 sample like the "marker.js" of 5.1 sample, but i didn't do lots of changes, and it doesn't work. can you advise me  some tutorial or other instruction to follow please? I read the documentation but still have some doubt.

 

Thanks in advance

Brus

Hi there!

I tested your changes and if you call World.loadPoisFromJsonData(myJsonData) in the requestDataFromLocal method it should load the jsonData defined in the "myJsonData.js"-File. If you want to customize the poiData stored in it you can easily change the coordinates of the pois to something in your vicinity and they will be shown at the set position.

Concerning the onClickTrigger as Andreas already mentioned, you should add the World.onMarkerSelected(marker) - method to the Marker.prototype.getOnClickTrigger method, just like in the marker.js file of Sample 5.1. Of course you also have to implement the method itself just like Sample 5.1.: 

onMarkerSelected: function onMarkerSelectedFn(marker) {

// notify native environment

document.location = "architectsdk://markerselected?id=" + marker.poiData.id;

}

 

This triggers the "public boolean urlWasInvoked(String uriString)" method. Which allows you to handle JS events in your native code. I may refer you to the SamplePoidataFromNativeAndUrlListenerActivity-class in the SDKSamples project and the SDK documentation to get further information about this method and the intrinsics behind it.

 

Hope that helps!

 

Markus

 

Hi Markus, thanks you too for your kind reply.

 

About the onClickTrigger method i solved like you suggest to me. Thanks a lot.

 

Abuout the first problem: of course i edited the "myJsonData.js"

file with the lat, long, name and description of my POI, but i don't know why everytiime i run the example the POI are in different position. If you need i can give you the screenshot of three or four run of the application so you could understand better.

I uploaded also the myJsonData.js file and the poiFromLocal.js files if you want to see my changes.

http://d.pr/f/2hmo

 

kind regards 

Brus

Hi again!

I had a look at your files and it seems that you still call the "Helper.bringPlacesToUser" method. In order to visualize the POIs the myJsonData.js file at the correct lat/lon you need to comment that line and only call "World.loadPoisFromJsonData(myJsonData);" in the requestDataFromLocal-method.

eg.

// request POI data

requestDataFromLocal: function requestDataFromLocalFn(lat, lon) {

 

World.loadPoisFromJsonData(myJsonData);

}

 

Let me know if that helped.

Markus

 

Hi again Markus,

 

First of all thanks for your help. I commented the line you said (there was also the comment in the code suggesting that  :P), and edited the call of the "World.loadPoisFromJsonData(myJsonData);" method. I compile, run the sample in my Gnexus and the "JSON object is loaded properly" but my POIs doesn't appear unfortunately. Now, i really don't understand where i'm making mistake.

 

Have you got any other suggestion?

If needed, once again i uploaded a zip file containing the files edited.   http://d.pr/f/wDVR

 

Thanks for your help, i appreciate a lot.

 

Kind regards

 

Brus

Hi again!

I again checked your code and It doesn't seem that there is an obvious error in it. Maybe the problem is that your own location is too away from your POIs. Could you please check the location that is passed to the locationChanged(lat, lon) method in javascript is close enough to the POIs (within a couple of kms). If not you could adjust the AR.context.scene.cullingDistance - value of your AR world via javascript.

Hope that helps

Markus

Hi Markus!

Now, IT WORKS. Your worth was to understand that my distance from the lat/long of the POIs in myJsonData.js was too far. I changed lat/long with some nearest me and it finally works! 

Thanks a lot for your kind patience and help, i appreciated a lot.

 

Kind regards

Brus

Hi friend,

I read all your threads so i am requesting you because i am new here

  Near me This feature will produce an augmented view of the surrounding utilising the mobile devices camera within a set radius to provide the user with POI?s within walking, short driving distance. These POI?s will be added and subtracted by the app team at their discretion. The ability to add a logo or icon to the information screen would be ideal to be able to distinguish the difference between POI?s, and if no icon is added the default app icon will be set as default.....

 

i have SDK ,Sample example but i am confusing how to mix  code....so please can you give me any demo for how to show near by POIs  please..

Hi There!

First of all thanks for the interest in our SDK. What you are describing is a basic usecase for Augmented Reality which is easily realisable with our SDK. I strongly recommend you to read the documentation and getting started guide that comes with our SDK. Especially the Point of Interest (POI) examples like, "Point at Location" or "Multiple POIs" should give you a great hint on how to create pois at geolocations. Please go through those examples and if you have any specific questions concerning the functionality feel free to ask.

Hope that helps,

Markus

Hi

I've been using wikitude samples- Multiple POIs.I've added the location of the POI nearer to my location as you have said but while opening the camera it always saying "trying to find out where you are" and no POI are displayed.Ive added two POI's at different locations nearer to me.Where have I gone wrong ?

var World = {

// true once data was fetched

initiallyLoadedData: false,

 

// different POI-Marker assets

markerDrawable_idle: null,

markerDrawable_selected: null,

 

// list of AR.GeoObjects that are currently shown in the scene / World

markerList: ,

 

// The last selected marker

currentMarker: null,

 

// called to inject new POI data

loadPoisFromJsonData: function loadPoisFromJsonDataFn(poiData) {

// empty list of visible markers

World.markerList = ;

 

// start loading marker assets

World.markerDrawable_idle = new AR.ImageResource("assets/marker_idle.png");

World.markerDrawable_selected = new AR.ImageResource("assets/marker_selected.png");

 

// loop through POI-information and create an AR.GeoObject (=Marker) per POI

for (var currentPlaceNr = 0; currentPlaceNr < poiData.length; currentPlaceNr++) {

var singlePoi = {

"id": poiData.id,

"latitude": parseFloat(poiData.latitude),

"longitude": parseFloat(poiData.longitude),

"altitude": parseFloat(poiData.altitude),

"title": poiData.name,

"description": poiData.description

};

 

/*

To be able to deselect a marker while the user taps on the empty screen, 

the World object holds an array that contains each marker.

*/

World.markerList.push(new Marker(singlePoi));

}

 

World.updateStatusMessage(currentPlaceNr + ' places 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) {

/* 

requestDataFromLocal with the geo information as parameters (latitude, longitude) creates different poi data to a random location in the user's vicinity.

*/

World.requestDataFromLocal(lat, lon);

World.initiallyLoadedData = true;

}

},

 

// fired when user pressed maker in cam

onMarkerSelected: function onMarkerSelectedFn(marker) {

 

// deselect previous marker

if (World.currentMarker) {

if (World.currentMarker.poiData.id == marker.poiData.id) {

return;

}

World.currentMarker.setDeselected(World.currentMarker);

}

 

// highlight current one

marker.setSelected(marker);

World.currentMarker = marker;

},

 

// screen was clicked but no geo-object was hit

onScreenClick: function onScreenClickFn() {

if (World.currentMarker) {

World.currentMarker.setDeselected(World.currentMarker);

}

},

 

// request POI data

requestDataFromLocal: function requestDataFromLocalFn(centerPointLatitude, centerPointLongitude) {

var poisToCreate = 20;

var poiData = ;

 

 

poiData.push({

                                                       "id": 1,

                                                                "longitude":80.235967,                 

                                                                "latitude":13.058403,

                                                                "description": ("JESUS "),

                                                                "altitude": "00.0",

                                                                "name": ("POI#" + ( 1))});

           poiData.push({                                                     

                                                                

                                                                "id": 2,

                                                                "longitude":80.236028,                       

                                                                "latitude":13.058263,

                                                                "description": ("A BLOCK "),

                                                                "altitude": "00.0",

                                                                "name": ("POI#" + (2))});

                                               

 

World.loadPoisFromJsonData(poiData);

}

 

};

 

/* 

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;

 

/*

To detect clicks where no drawable was hit set a custom function on AR.context.onScreenClick where the currently selected marker is deselected.

*/

AR.context.onScreenClick = World.onScreenClick;

Hi, could be obvious, but did you turn on location services in your smartphone?

Yes the location are enabled in my smart phone.Is the code right then ?
Login or Signup to post a comment