fix error handling. It happens when use mapbox in oflline

Fixed Crash. Mapbox was crashing when try use it in offline mode.
added check if variables in not nil before making dangerous operation.