com.mapbox.mapboxsdk.annotations.IconFactory Java Examples

The following examples show how to use com.mapbox.mapboxsdk.annotations.IconFactory. 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: ThemeSwitcher.java    From graphhopper-navigation-android with MIT License 5 votes vote down vote up
/**
 * Returns a map marker {@link Icon} based on the current theme setting.
 *
 * @param context to retrieve an instance of {@link IconFactory}
 * @return {@link Icon} map marker dark or light
 */
public static Icon retrieveThemeMapMarker(Context context) {
  TypedValue destinationMarkerResId = resolveAttributeFromId(context, R.attr.navigationViewDestinationMarker);
  int markerResId = destinationMarkerResId.resourceId;
  IconFactory iconFactory = IconFactory.getInstance(context);
  return iconFactory.fromResource(markerResId);
}
 
Example #2
Source File: EndNavigationActivity.java    From graphhopper-navigation-android with MIT License 5 votes vote down vote up
private void drawPaella() {
  Icon paellaIcon = IconFactory.getInstance(this).fromResource(R.drawable.paella_icon);
  paella = navigationView.retrieveNavigationMapboxMap().retrieveMap().addMarker(new MarkerOptions()
    .position(new LatLng(37.760615, -122.424306))
    .icon(paellaIcon)
  );
}
 
Example #3
Source File: Utils.java    From graphhopper-navigation-android with MIT License 5 votes vote down vote up
/**
 * Demonstrates converting any Drawable to an Icon, for use as a marker icon.
 */
public static Icon drawableToIcon(@NonNull Context context, @DrawableRes int id) {
  Drawable vectorDrawable = ResourcesCompat.getDrawable(context.getResources(), id, context.getTheme());
  Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(),
    vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
  Canvas canvas = new Canvas(bitmap);
  vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
  vectorDrawable.draw(canvas);
  return IconFactory.getInstance(context).fromBitmap(bitmap);
}
 
Example #4
Source File: Images.java    From WhereAreTheEyes with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static final Icon getCameraIcon() {
    if( cameraIcon != null )
        return cameraIcon;
    IconFactory iconFactory = IconFactory.getInstance(mainContext);
    cameraIcon = iconFactory.fromResource(R.drawable.map_pin);
    return cameraIcon;
}
 
Example #5
Source File: NavigationLauncherActivity.java    From graphhopper-navigation-example with Apache License 2.0 4 votes vote down vote up
@Override
public void onPostExecuteGeocodingSearch(List<GeocodingLocation> locations) {
    clearGeocodingResults();
    markers = new ArrayList<>(locations.size());

    if (locations.isEmpty()) {
        onError(R.string.error_geocoding_no_location);
        return;
    }

    List<LatLng> bounds = new ArrayList<>();
    Location lastKnownLocation = getLastKnownLocation();
    if (lastKnownLocation != null)
        bounds.add(new LatLng(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude()));

    for (GeocodingLocation location : locations) {
        GeocodingPoint point = location.getPoint();
        MarkerOptions markerOptions = new MarkerOptions();
        LatLng latLng = new LatLng(point.getLat(), point.getLng());
        markerOptions.position(latLng);
        bounds.add(latLng);
        markerOptions.title(location.getName());
        String snippet = "";
        if (location.getStreet() != null) {
            snippet += location.getStreet();
            if (location.getHousenumber() != null)
                snippet += " " + location.getHousenumber();
            snippet += "\n";
        }
        if (location.getCity() != null) {
            if (location.getPostcode() != null)
                snippet += location.getPostcode() + " ";
            snippet += location.getCity() + "\n";
        }
        if (location.getCountry() != null)
            snippet += location.getCountry() + "\n";
        if (location.getOsmId() != null) {
            snippet += "OSM-Id: " + location.getOsmId() + "\n";
            if (location.getOsmKey() != null)
                snippet += "OSM-Key: " + location.getOsmKey() + "\n";
            if (location.getOsmType() != null)
                snippet += "OSM-Type: " + location.getOsmType() + "\n";
        }
        snippet += "\n\n Tap on info window\n to add point to route";
        if (!snippet.isEmpty())
            markerOptions.snippet(snippet);
        markerOptions.icon(IconFactory.getInstance(this.getApplicationContext()).fromResource(R.drawable.ic_map_marker));
        markers.add(mapboxMap.addMarker(markerOptions));
    }

    // For bounds we need at least 2 entries
    if (bounds.size() >= 2) {
        LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
        boundsBuilder.includes(bounds);
        animateCameraBbox(boundsBuilder.build(), CAMERA_ANIMATION_DURATION, padding);
    } else if (bounds.size() == 1) {
        // If there is only 1 result (=>current location unknown), we just zoom to that result
        animateCamera(bounds.get(0));
    }
    hideLoading();
}
 
Example #6
Source File: AnnotationsFactory.java    From AirMapSDK-Android with Apache License 2.0 4 votes vote down vote up
public AnnotationsFactory(Context context) {
    this.context = context;
    cornerIcon = IconFactory.getInstance(context).fromBitmap(getBitmapForDrawable(context, R.drawable.white_circle));
    midpointIcon = IconFactory.getInstance(context).fromBitmap(getBitmapForDrawable(context, R.drawable.gray_circle));
    intersectionIcon = IconFactory.getInstance(context).fromBitmap(getBitmapForDrawable(context, R.drawable.intersection_circle));
}