Skip to main content
12-Amethyst
January 22, 2016
Solved

Example of creating and populating an INFOTABLE in a client side widget

  • January 22, 2016
  • 1 reply
  • 6372 views

I'm looking for an example of how to create and populate (LOCATION) entries in an INFOTABLE via the client-side widget (widget.runtime.js).

Thanks!

Cletus

Best answer by cdsouza

The following code snippet works for me.  Lines 1-16 create an infotable.  18-35 (really 27-32) populate the infotable with data.

var infoTable = new Object();

infoTable = {

    'dataShape': {

        fieldDefinitions: {},

        name: 'RegionLocations',

        description: 'Google Maps Region Locations'

        },

    'name': 'Region',

    'description': 'Google Maps Region',

    'rows': [{}]

};   

infoTable.dataShape.fieldDefinitions['Location'] = {

    name: 'Location',

    baseType: 'LOCATION'

};

for( var i = 0; i < latLngArray.length; i++ )

{

    var latLng = latLngArray;

    var newLocation = new Object();

    newLocation.latitude = latLng.lat();

    newLocation.longitude = latLng.lng();

    newLocation.elevation = 0;

    newLocation.units = 'WGS84';               

    var newRow = {};

    infoTable.rows.push(newRow);

    var row = infoTable.rows;

    newRow['Location'] = newLocation;

    infoTable.rows = newRow;

    delete row;

}

1 reply

cdsouza12-AmethystAuthorAnswer
12-Amethyst
January 22, 2016

The following code snippet works for me.  Lines 1-16 create an infotable.  18-35 (really 27-32) populate the infotable with data.

var infoTable = new Object();

infoTable = {

    'dataShape': {

        fieldDefinitions: {},

        name: 'RegionLocations',

        description: 'Google Maps Region Locations'

        },

    'name': 'Region',

    'description': 'Google Maps Region',

    'rows': [{}]

};   

infoTable.dataShape.fieldDefinitions['Location'] = {

    name: 'Location',

    baseType: 'LOCATION'

};

for( var i = 0; i < latLngArray.length; i++ )

{

    var latLng = latLngArray;

    var newLocation = new Object();

    newLocation.latitude = latLng.lat();

    newLocation.longitude = latLng.lng();

    newLocation.elevation = 0;

    newLocation.units = 'WGS84';               

    var newRow = {};

    infoTable.rows.push(newRow);

    var row = infoTable.rows;

    newRow['Location'] = newLocation;

    infoTable.rows = newRow;

    delete row;

}