Restructure code to allow automatic reaction to callback when calling `map.locate()`