Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
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
Solved! Go to Solution.
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;
}
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;
}