The file "
mapComponent.js" refers to CDF's old map component, which is not what you are using.
On the NewMapComponent you can set the center latitude/longitude in the following ways:
1) within preExecution, which runs before any query takes place, you can set:
this.centerLatitude = 38.660294;
this.centerLongitude = -9.298992;
2) within postFetch, which has access to your data, you can set:
Code:
function(json){
// assuming a data layout of "latitude,longitude,...."
var latitudeList = _.pluck(json.resultset, 0);
var longitudeList = _.pluck(json.resultset, 1);
var centerLat = _.reduce(latitudeList, function(agg, value){ return agg + value;}, 0) / latitudeList.length
var centerLon = _.reduce(longitudeList, function(agg, value){ return agg + value;}, 0) / longitudeList.length
this.configuration.viewport.center = {
latitude: centerLat,
longitude: centerLon
}
return json;
}
The reason for the two mechanisms is that the component builds a "this.configuration" object immediately after preExecution. This allows grouping and cross-validation of options, as well as proper conciliation with the default settings.