Get Node ID in hook_field_formatter_view()
As the Field Collection docs says:


  A field collection is internally represented as an entity, which is embedded in the host entity


So what you need to do in your field, is:


Test if it's container is a node. This case works already.
Test if it's a Field Collection entity.
Fallback to situation when you can't obtain parent container or it's an unexpected entity.


Now we'll take care about 2. point. If you can safely assume your field is always in a node, you can use code from answer by Chris Muench:

$model = entity_load_single('field_collection_item', $model_id);
$node = $model-&gt;hostEntity();
echo $node-&gt;nid;


Note that you are writing formatter, and it means you have no guarantee that host entity will always be a node. If it's not, go to point 3 on my list.