Java Code Examples for com.mapbox.mapboxsdk.maps.MapView#addOnDidFinishLoadingStyleListener()

The following examples show how to use com.mapbox.mapboxsdk.maps.MapView#addOnDidFinishLoadingStyleListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationManager.java    From mapbox-plugins-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@UiThread
protected AnnotationManager(MapView mapView, final MapboxMap mapboxMap, Style style,
                            CoreElementProvider<L> coreElementProvider,
                            DraggableAnnotationController<T, D> draggableAnnotationController,
                            String belowLayerId, final GeoJsonOptions geoJsonOptions) {
  this.mapboxMap = mapboxMap;
  this.style = style;
  this.belowLayerId = belowLayerId;
  this.coreElementProvider = coreElementProvider;

  if (!style.isFullyLoaded()) {
    throw new RuntimeException("The style has to be non-null and fully loaded.");
  }

  mapboxMap.addOnMapClickListener(mapClickResolver = new MapClickResolver());
  mapboxMap.addOnMapLongClickListener(mapClickResolver);
  this.draggableAnnotationController = draggableAnnotationController;
  draggableAnnotationController.injectAnnotationManager(this);

  initializeSourcesAndLayers(geoJsonOptions);

  mapView.addOnDidFinishLoadingStyleListener(new MapView.OnDidFinishLoadingStyleListener() {
    @Override
    public void onDidFinishLoadingStyle() {
      mapboxMap.getStyle(new Style.OnStyleLoaded() {
        @Override
        public void onStyleLoaded(@NonNull Style loadedStyle) {
          AnnotationManager.this.style = loadedStyle;
          initializeSourcesAndLayers(geoJsonOptions);
        }
      });
    }
  });
}
 
Example 2
Source File: TrafficPlugin.java    From mapbox-plugins-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Create a traffic plugin.
 *
 * @param mapView    the MapView to apply the traffic plugin to
 * @param mapboxMap  the MapboxMap to apply traffic plugin with
 * @param belowLayer the layer id where you'd like the traffic to display below
 */
public TrafficPlugin(@NonNull MapView mapView, @NonNull MapboxMap mapboxMap, @NonNull Style style,
                     @Nullable String belowLayer) {
  if (!style.isFullyLoaded()) {
    throw new RuntimeException("The style has to be non-null and fully loaded.");
  }

  this.mapboxMap = mapboxMap;
  this.style = style;
  this.belowLayer = belowLayer;
  mapView.addOnDidFinishLoadingStyleListener(new StyleLoadHandler(this));
}