You need to create a Placemark object using createPlacemark()
.
You probably don't need to create an array of Placemarks since the google earth API keeps the list of placemarks from which you can iterate using ge.getFeatures().getChildNodes()
.
for(var i = 0; i < data.length; i++ )
{
// Create the Placemark
var placemark = ge.createPlacemark('');
// Set the placemark's location.
point[i] = ge.createPoint('');
point[i].setLatitude( data[i].lat );
point[i].setLongitude( data[i].lon );
placemark.setGeometry(point[i]);
// Add the placemark to Earth.
ge.getFeatures().appendChild(placemark);
}
Also, probably won't need array of points since have the array of data. Can simplify this to the following:
for(var i = 0; i < data.length; i++ )
{
// Create the Placemark
var placemark = ge.createPlacemark('');
// Set the placemark's location.
var point = ge.createPoint('');
point.setLatitude( data[i].lat );
point.setLongitude( data[i].lon );
placemark.setGeometry(point);
// Add the placemark to Earth.
ge.getFeatures().appendChild(placemark);
}
If you want to compute the center bounds of a bunch of generic KML features you can use an Google Earth API extension: https://code.google.com/p/earth-api-utility-library/wiki/GEarthExtensionsDomReference#computeBounds(object)
But if you just have an array of points then you can easily compute the center manually then set the LookAt to the computed center view point.
The final initCB() would look like this:
function initCB(instance) {
ge = instance;
ge.getWindow().setVisibility(true);
ge.getNavigationControl().setVisibility(ge.VISIBILITY_HIDE);
var latSum = 0.0;
var lonSum = 0.0;
for(var i = 0; i < data.length; i++ )
{
// Set the placemark's location.
var point = ge.createPoint('');
point.setLatitude( data[i].lat );
point.setLongitude( data[i].lon );
latSum += data[i].lat;
lonSum += data[i].lon;
var placemark = ge.createPlacemark(data[i].content);
placemark.setGeometry(point);
// Add the placemark to Earth.
ge.getFeatures().appendChild(placemark);
}
// Create LookAt at the center view point
var lookAt = ge.createLookAt('');
lookAt.set(latSum / data.length, lonSum / data.length, 0,
ge.ALTITUDE_RELATIVE_TO_GROUND, 0, 0, 20000);
ge.getView().setAbstractView(lookAt);
}