Fixed: I tried call the initlocation way before the map even existed, so I just moved the function call to on map created and it worked.