Start a new topic

How to load POI data from database with Titanium

How to load POI data from database with Titanium


Hello All

I use the Wikitude sample given with Titanium.

I see that the POI data is loaded from a JSon file. What I want to do is to load the POI data from a DB file.

I modify the sample code in the folder : 4_ObtainPoiData_2_FromLocalResource

 

The file I modify is this one : fromLocalResource.jsl

HERE'S THE CODE I ADD :

------------------------------------------------------------------------------------------------------------

var db = Titanium.Database.install('MyDatabase.db','mydb');

// Database Connection

var PoiValue = db.execute('SELECT id, latitude, longitude, altitude", name, desc, number FROM MyTable;');

    while (PoiValue.isValidRow()) {

        var singlePoi = {

        "id": PoiValue.fieldByName('id'),

        "latitude": PoiValue.fieldByName('latitude'),

        "longitude": PoiValue.fieldByName('longitude'),

        "altitude": PoiValue.fieldByName('altitude'),

        "title": PoiValue.fieldByName('name'),

        "description": PoiValue.fieldByName('description'),

    };

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

    PoiValue.next();

}

 

PoiValue.close();

------------------------------------------------------------------------------------------------------------

 

Is the script is correct ?

Can I use this script in a JSL file ?

What language do I need to use in a JLS file ? Javascript ??

 

Thanks for all our help

 

 

Hi Phil,
.jsl files are regular .js files. We needed to rename them to .jsl because otherwise the Titanium Studio would try to convert them into native code and the files do not appear in the final app bundle. So you can use regular JavaScript ;)
 

I'm not sure how to use the Titanium DB API but as long as you can get your poi information out of it and pass them in the same format as we defined in our samples, you should be able to use them in your application.

 

(Please close the thread you created that links to this question!)

Hello

OK but if I put Titanium DB API in *.jsl file, that means that my code won't be compiled ?

So if I understand, I cannot use Titanium DB API code in the jsl file ?

Is it that it means ? So what's the solution ? 

 

 
Login or Signup to post a comment