private boolean changeMapSource(@NonNull final MapSource newSource) {
        final MapSource oldSource = Settings.getMapSource();
        final boolean restartRequired = oldSource == null || !MapProviderFactory.isSameActivity(oldSource, newSource);

        Settings.setMapSource(newSource);
        currentSourceId = newSource.getNumericalId();

        if (restartRequired) {
            mapRestart();
        } else if (mapView != null) {  // changeMapSource can be called by onCreate()
            mapOptions.mapState = currentMapState();
            mapView.setMapSource();
            // re-center the map
            centered = false;
            centerMap(mapOptions.geocode, mapOptions.searchResult, mapOptions.coords, mapOptions.mapState);
            // re-build menues
            ActivityMixin.invalidateOptionsMenu(activity);
        }

        mapSource = newSource;

        final int mapAttributionViewId = mapSource.getMapProvider().getMapAttributionViewId();
        if (mapAttributionViewId > 0) {
            final View mapAttributionView = activity.findViewById(mapAttributionViewId);
            if (mapAttributionView != null) {
                mapAttributionView.setOnClickListener(
                        new NewMap.MapAttributionDisplayHandler(() -> this.mapSource.calculateMapAttribution(mapAttributionView.getContext())));
            }
        }

        return restartRequired;
    }
Restart the current activity if the map provider has changed, or change the map source if needed.

@param newSource the new map source, which can be the same as the current one
@return true if a restart is needed, false otherwise
main/src/main/java/cgeo/geocaching/maps/CGeoMap.java