* @return String with the rendered Javascript
*/
public String renderAfterConstructorJs() {
StringBuilder builder = new StringBuilder();
Map map = getModelObject();
// handle additional map building code
if (map.getLayers() != null) {
for (Layer layer : map.getLayers()) {
if (layer.getSource() != null && layer.getSource() instanceof VectorSource) {
VectorSource vectorSource = (VectorSource) layer.getSource();
if (vectorSource.getFeatures() != null) {
for (Feature feature : vectorSource.getFeatures()) {
builder.append(feature.renderAfterConstructorJs());
}
}
}
// create vector data sources for clusters before the map
if (layer.getSource() != null && layer.getSource() instanceof Cluster) {
Cluster source = (Cluster) layer.getSource();
// add a listener to reload our cluster data
if(source.getSource() instanceof ServerVector) {
builder.append(map.getJsId() + ".getView().on('propertychange', function(event) {");
builder.append(renderClusterLoaderJs(map, layer));
builder.append("});");
}
// kick off an initial cluster load