map.getLayerCollection().add(layer);
map.fullView();
}
else
{
ShapeFeature f = createFeature(g);
layer.getFeatures().insert(f);
f.setFeatureClass(layer.getFeatures());
EnvelopeBuf eb = new EnvelopeBuf(layer.getEnvelop());
eb.mergeEnvelop(g.getEnvelop());
((FeatureSet)layer.getFeatures()).setEnvelope(eb.toEnvelop());
map.getLayerCollection().reComputeEnvelop();