Search in sources :

Example 1 with MapFragment

use of org.odk.collect.geo.maps.MapFragment in project collect by opendatakit.

the class MapProvider method createMapFragment.

/**
 * Gets a new MapFragment from the selected MapConfigurator.
 */
@Override
public MapFragment createMapFragment(@NonNull Context context) {
    MapConfigurator cftor = getConfigurator();
    MapFragment map = cftor.createMapFragment(context);
    if (map != null) {
        configuratorsByMap.put(map, cftor);
        return map;
    }
    cftor.showUnavailableMessage(context);
    return null;
}
Also used : MapFragment(org.odk.collect.geo.maps.MapFragment)

Example 2 with MapFragment

use of org.odk.collect.geo.maps.MapFragment in project collect by opendatakit.

the class MapProvider method onMapFragmentStart.

void onMapFragmentStart(MapFragment map) {
    MapConfigurator cftor = configuratorsByMap.get(map);
    if (cftor != null) {
        Settings generalSettings = PrefUtils.getSharedPrefs();
        Settings.OnSettingChangeListener listener = key -> {
            if (cftor.getPrefKeys().contains(key)) {
                map.applyConfig(cftor.buildConfig(generalSettings));
            }
        };
        map.applyConfig(cftor.buildConfig(generalSettings));
        generalSettings.registerOnSettingChangeListener(listener);
        listenersByMap.put(map, listener);
    }
}
Also used : Context(android.content.Context) NonNull(androidx.annotation.NonNull) Singleton(javax.inject.Singleton) PrefUtils(org.odk.collect.android.preferences.PrefUtils) KEY_BASEMAP_SOURCE(org.odk.collect.settings.keys.ProjectKeys.KEY_BASEMAP_SOURCE) MapFragmentFactory(org.odk.collect.geo.maps.MapFragmentFactory) Map(java.util.Map) R(org.odk.collect.android.R) KEY_USGS_MAP_STYLE(org.odk.collect.settings.keys.ProjectKeys.KEY_USGS_MAP_STYLE) WeakHashMap(java.util.WeakHashMap) KEY_MAPBOX_MAP_STYLE(org.odk.collect.settings.keys.ProjectKeys.KEY_MAPBOX_MAP_STYLE) MapFragment(org.odk.collect.geo.maps.MapFragment) BASEMAP_SOURCE_STAMEN(org.odk.collect.settings.keys.ProjectKeys.BASEMAP_SOURCE_STAMEN) WmsOption(org.odk.collect.android.geo.OsmDroidMapConfigurator.WmsOption) BASEMAP_SOURCE_GOOGLE(org.odk.collect.settings.keys.ProjectKeys.BASEMAP_SOURCE_GOOGLE) GoogleMapTypeOption(org.odk.collect.android.geo.GoogleMapConfigurator.GoogleMapTypeOption) MapboxUrlOption(org.odk.collect.android.geo.MapboxMapConfigurator.MapboxUrlOption) BASEMAP_SOURCE_OSM(org.odk.collect.settings.keys.ProjectKeys.BASEMAP_SOURCE_OSM) KEY_GOOGLE_MAP_STYLE(org.odk.collect.settings.keys.ProjectKeys.KEY_GOOGLE_MAP_STYLE) Style(com.mapbox.mapboxsdk.maps.Style) BASEMAP_SOURCE_USGS(org.odk.collect.settings.keys.ProjectKeys.BASEMAP_SOURCE_USGS) KEY_CARTO_MAP_STYLE(org.odk.collect.settings.keys.ProjectKeys.KEY_CARTO_MAP_STYLE) GoogleMap(com.google.android.gms.maps.GoogleMap) Settings(org.odk.collect.shared.settings.Settings) BASEMAP_SOURCE_MAPBOX(org.odk.collect.settings.keys.ProjectKeys.BASEMAP_SOURCE_MAPBOX) BASEMAP_SOURCE_CARTO(org.odk.collect.settings.keys.ProjectKeys.BASEMAP_SOURCE_CARTO) Settings(org.odk.collect.shared.settings.Settings)

Aggregations

MapFragment (org.odk.collect.geo.maps.MapFragment)2 Context (android.content.Context)1 NonNull (androidx.annotation.NonNull)1 GoogleMap (com.google.android.gms.maps.GoogleMap)1 Style (com.mapbox.mapboxsdk.maps.Style)1 Map (java.util.Map)1 WeakHashMap (java.util.WeakHashMap)1 Singleton (javax.inject.Singleton)1 R (org.odk.collect.android.R)1 GoogleMapTypeOption (org.odk.collect.android.geo.GoogleMapConfigurator.GoogleMapTypeOption)1 MapboxUrlOption (org.odk.collect.android.geo.MapboxMapConfigurator.MapboxUrlOption)1 WmsOption (org.odk.collect.android.geo.OsmDroidMapConfigurator.WmsOption)1 PrefUtils (org.odk.collect.android.preferences.PrefUtils)1 MapFragmentFactory (org.odk.collect.geo.maps.MapFragmentFactory)1 BASEMAP_SOURCE_CARTO (org.odk.collect.settings.keys.ProjectKeys.BASEMAP_SOURCE_CARTO)1 BASEMAP_SOURCE_GOOGLE (org.odk.collect.settings.keys.ProjectKeys.BASEMAP_SOURCE_GOOGLE)1 BASEMAP_SOURCE_MAPBOX (org.odk.collect.settings.keys.ProjectKeys.BASEMAP_SOURCE_MAPBOX)1 BASEMAP_SOURCE_OSM (org.odk.collect.settings.keys.ProjectKeys.BASEMAP_SOURCE_OSM)1 BASEMAP_SOURCE_STAMEN (org.odk.collect.settings.keys.ProjectKeys.BASEMAP_SOURCE_STAMEN)1 BASEMAP_SOURCE_USGS (org.odk.collect.settings.keys.ProjectKeys.BASEMAP_SOURCE_USGS)1