What can i do to overcome this?
Nothing - the cloning algorithm used by postMessage
does not transport prototypes and functions. Reconstructing them on the other side is necessary.
Right now i'm simply looping over the results and reconstructing the GeoPoint objects, it works but seems very bad.
No, that's what needs to be done:
var newCluster = messageData.cluster.map(function(likeapoint) {
var point = new GeoPoint();
for (p in likeapoint) // maybe a static list of copied property names
point[p] = likeapoint[p];// is faster, but not as flexible
return point;
})
// since all properties are settable as arguments in this specific case:
var newCluster = messageData.cluster.map(function(likeapoint) {
return new GeoPoint(likeapoint.lat_, likeapoint.long_);
})