When showing an object, the map location is not set until the vector layer has finished loading. Thus map.getCenter() returns null. Registering the events earlier avoids the need to call updateLocation manually at all.
Move it to index.js/edit.js and eliminate the global doSearch function. Not enough code is shared to justify it.