com.google.android.gms.maps.model.PatternItem Java Examples

The following examples show how to use com.google.android.gms.maps.model.PatternItem. 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: MapUtils.java    From ridesharing-android with MIT License 6 votes vote down vote up
public static GoogleMapConfig.Builder getBuilder(Context context) {
    int width = context.getResources().getDisplayMetrics().widthPixels;
    int height = context.getResources().getDisplayMetrics().heightPixels;
    int mapRouteWidth = context.getResources().getDimensionPixelSize(R.dimen.map_route_width);
    GoogleMapConfig.TripOptions tripOptions = GoogleMapConfig.newTripOptions()
            .tripDestinationMarker(new MarkerOptions()
                    .anchor(0.5f, 0.5f)
                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_destination_marker)))
            .tripPassedRoutePolyline(null)
            .tripComingRoutePolyline(new PolylineOptions()
                    .width(mapRouteWidth)
                    .color(Color.BLACK)
                    .pattern(Collections.<PatternItem>singletonList(new Dash(mapRouteWidth))));
    return GoogleMapConfig.newBuilder(context)
            .tripOptions(tripOptions)
            .boundingBoxDimensions(width, height / 3);
}
 
Example #2
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the list of latitude and longitude to the polyline options.
 *
 * @param context         A context.
 * @param locationList    A list of latitude and longitude.
 * @param width           Width of the polyline in screen pixels.
 * @param color           Color of the polyline as a 32-bit ARGB color.
 * @param clickable       Is polyline clickable.
 * @param patternItemList Stroke pattern for the polyline.
 * @return Options for a polyline.
 * @since 1.2.0
 */
public static PolylineOptions createPolyline(
        @NonNull Context context,
        @Nullable ArrayList<LatLng> locationList,
        @Dimension(unit = Dimension.DP) int width,
        @ColorInt int color,
        boolean clickable,
        @Nullable List<PatternItem> patternItemList
) {
    return createPolyline(
            context,
            locationList,
            width,
            color,
            clickable,
            JointType.DEFAULT,
            null,
            null,
            patternItemList
    );
}
 
Example #3
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the list of latitude and longitude to the polyline options in transit mode.
 *
 * @param context                A context.
 * @param stepList               A list of latitude and longitude for the steps.
 * @param transitWidth           Width of the polyline in screen pixels for transit polyline.
 * @param transitColor           Color of the polyline as a 32-bit ARGB color for transit polyline.
 * @param transitPatternItemList Stroke pattern for the polyline for transit polyline.
 * @param walkingWidth           Width of the polyline in screen pixels for walking polyline.
 * @param walkingColor           Color of the polyline as a 32-bit ARGB color for walking polyline.
 * @param walkingPatternItemList Stroke pattern for the polyline for walking polyline.
 * @return Options for a polyline.
 * @since 1.2.0
 */
public static ArrayList<PolylineOptions> createTransitPolyline(
        @NonNull Context context,
        @Nullable List<Step> stepList,
        @Dimension(unit = Dimension.DP) int transitWidth,
        @Nullable List<PatternItem> transitPatternItemList,
        @ColorInt int transitColor,
        @Dimension(unit = Dimension.DP) int walkingWidth,
        @ColorInt int walkingColor,
        @Nullable List<PatternItem> walkingPatternItemList) {
    return createTransitPolyline(
            context,
            stepList,
            transitWidth,
            transitColor,
            transitPatternItemList,
            walkingWidth,
            walkingColor,
            walkingPatternItemList,
            true,
            JointType.DEFAULT,
            null,
            null
    );
}
 
Example #4
Source File: GeoJsonPolygonStyleTest.java    From android-maps-utils with Apache License 2.0 5 votes vote down vote up
@Test
public void testStrokePattern() {
    List<PatternItem> strokePatternItems = new ArrayList<>();
    strokePatternItems.add(new Dot());

    polygonStyle.setStrokePattern(strokePatternItems);
    assertEquals(strokePatternItems, polygonStyle.getStrokePattern());
    assertEquals(strokePatternItems, polygonStyle.toPolygonOptions().getStrokePattern());
}
 
Example #5
Source File: ThirdExampleActivity.java    From Curve-Fit with Apache License 2.0 5 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    this.map = googleMap;
    curveManager = new CurveManager(map);

    CurveOptions curveOptions = new CurveOptions();
    curveOptions.add(sourceLatLng);
    curveOptions.add(destinationLatLng);
    curveOptions.color(Color.DKGRAY);
    curveOptions.setComputePointsBasedOnScreenPixels(true);
    curveOptions.setAlpha(0.5f);
    curveOptions.width(12);
    List<PatternItem> pattern = Arrays.asList(new Dash(30), new Gap(30));
    curveOptions.pattern(pattern);
    curveOptions.geodesic(false);

    map.addMarker(new MarkerOptions()
            .position(sourceLatLng)
            .anchor(0.5f, 1f));
    map.addMarker(new MarkerOptions()
            .position(destinationLatLng)
            .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN))
            .anchor(0.5f, 1f));

    map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(56.14683221, 10.2079815), 14));
    curveManager.drawCurveAsync(curveOptions);
}
 
Example #6
Source File: PolygonDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
private List<PatternItem> getSelectedPattern(int pos) {
    switch (PATTERN_TYPE_NAME_RESOURCE_IDS[pos]) {
        case R.string.pattern_solid:
            return null;
        case R.string.pattern_dotted:
            return PATTERN_DOTTED;
        case R.string.pattern_dashed:
            return PATTERN_DASHED;
        case R.string.pattern_mixed:
            return PATTERN_MIXED;
        default:
            return null;
    }
}
 
Example #7
Source File: PolylineDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
private List<PatternItem> getSelectedPattern(int pos) {
    switch (PATTERN_TYPE_NAME_RESOURCE_IDS[pos]) {
        case R.string.pattern_solid:
            return null;
        case R.string.pattern_dotted:
            return PATTERN_DOTTED;
        case R.string.pattern_dashed:
            return PATTERN_DASHED;
        case R.string.pattern_mixed:
            return PATTERN_MIXED;
        default:
            return null;
    }
}
 
Example #8
Source File: CircleDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
private List<PatternItem> getSelectedPattern(int pos) {
    switch (PATTERN_TYPE_NAME_RESOURCE_IDS[pos]) {
        case R.string.pattern_solid:
            return null;
        case R.string.pattern_dotted:
            return PATTERN_DOTTED;
        case R.string.pattern_dashed:
            return PATTERN_DASHED;
        case R.string.pattern_mixed:
            return PATTERN_MIXED;
        default:
            return null;
    }
}
 
Example #9
Source File: PolyActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
/**
 * Styles the polygon, based on type.
 * @param polygon The polygon object that needs styling.
 */
private void stylePolygon(Polygon polygon) {
    String type = "";
    // Get the data object stored with the polygon.
    if (polygon.getTag() != null) {
        type = polygon.getTag().toString();
    }

    List<PatternItem> pattern = null;
    int strokeColor = COLOR_BLACK_ARGB;
    int fillColor = COLOR_WHITE_ARGB;

    switch (type) {
        // If no type is given, allow the API to use the default.
        case "alpha":
            // Apply a stroke pattern to render a dashed line, and define colors.
            pattern = PATTERN_POLYGON_ALPHA;
            strokeColor = COLOR_GREEN_ARGB;
            fillColor = COLOR_PURPLE_ARGB;
            break;
        case "beta":
            // Apply a stroke pattern to render a line of dots and dashes, and define colors.
            pattern = PATTERN_POLYGON_BETA;
            strokeColor = COLOR_ORANGE_ARGB;
            fillColor = COLOR_BLUE_ARGB;
            break;
    }

    polygon.setStrokePattern(pattern);
    polygon.setStrokeWidth(POLYGON_STROKE_WIDTH_PX);
    polygon.setStrokeColor(strokeColor);
    polygon.setFillColor(fillColor);
}
 
Example #10
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 5 votes vote down vote up
/**
 * Convert the list of latitude and longitude to the polyline options.
 *
 * @param context         A context.
 * @param locationList    A list of latitude and longitude.
 * @param width           Width of the polyline in screen pixels.
 * @param color           Color of the polyline as a 32-bit ARGB color.
 * @param clickable       Is polyline clickable.
 * @param jointType       Joint type for all vertices of the polyline except the start and end vertices.
 * @param startCap        Cap at the start vertex of the polyline.
 * @param endCap          Cap at the end vertex of the polyline.
 * @param patternItemList Stroke pattern for the polyline.
 * @return Options for a polyline.
 * @since 1.2.0
 */
public static PolylineOptions createPolyline(
        @NonNull Context context,
        @Nullable ArrayList<LatLng> locationList,
        @Dimension(unit = Dimension.DP) int width,
        @ColorInt int color,
        boolean clickable,
        int jointType,
        @Nullable Cap startCap,
        @Nullable Cap endCap,
        @Nullable List<PatternItem> patternItemList) {
    PolylineOptions rectLine = new PolylineOptions().width(dpToPx(context, width)).color(color).geodesic(true);
    rectLine.clickable(clickable);
    rectLine.jointType(jointType);
    if (patternItemList != null) {
        rectLine.pattern(patternItemList);
    }
    if (startCap != null) {
        rectLine.startCap(startCap);
    }
    if (endCap != null) {
        rectLine.endCap(endCap);
    }
    if (locationList != null && locationList.size() > 0) {
        for (LatLng location : locationList) {
            rectLine.add(location);
        }
    }
    return rectLine;
}
 
Example #11
Source File: SecondExampleActivity.java    From Curve-Fit with Apache License 2.0 5 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    this.map = googleMap;
    curveManager = new CurveManager(map);

    ArrayList<LatLng> latLngArrayList = new ArrayList<>();
    latLngArrayList.add(new LatLng(12.30548451, 76.65521267));
    latLngArrayList.add(new LatLng(19.81516491, 85.83133625));
    latLngArrayList.add(new LatLng(26.9124336, 75.7872709));
    latLngArrayList.add(new LatLng(28.596111, 83.820278));

    CurveOptions curveOptions = new CurveOptions();
    curveOptions.addAll(latLngArrayList);
    curveOptions.color(Color.DKGRAY);
    curveOptions.setComputePointsBasedOnScreenPixels(false);
    curveOptions.setAlpha(0.5f);
    curveOptions.width(10);
    List<PatternItem> pattern = Arrays.asList(new Dash(30), new Gap(20));
    curveOptions.pattern(pattern);
    curveOptions.geodesic(false);

    for (LatLng position : latLngArrayList) {
        new MarkerOptions().position(position);
        map.addMarker(new MarkerOptions().position(position));
    }
    map.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(21.146633, 79.088860), 5));

    curveManager.drawCurveAsync(curveOptions);
}
 
Example #12
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 4 votes vote down vote up
public PathOption setPatternItemList(List<PatternItem> patternItemList) {
    this.patternItemList = patternItemList;
    return this;
}
 
Example #13
Source File: CircleDemoActivity.java    From android-samples with Apache License 2.0 4 votes vote down vote up
public void setStrokePattern(List<PatternItem> pattern) {
    circle.setStrokePattern(pattern);
}
 
Example #14
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 4 votes vote down vote up
public TransitPathOption setWalkingPatternItemList(@Nullable List<PatternItem> walkingPatternItemList) {
    this.walkingPatternItemList = walkingPatternItemList;
    return this;
}
 
Example #15
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 4 votes vote down vote up
@Nullable
public List<PatternItem> getWalkingPatternItemList() {
    return walkingPatternItemList;
}
 
Example #16
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 4 votes vote down vote up
public TransitPathOption setTransitPatternItemList(@Nullable List<PatternItem> transitPatternItemList) {
    this.transitPatternItemList = transitPatternItemList;
    return this;
}
 
Example #17
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 4 votes vote down vote up
@Nullable
public List<PatternItem> getTransitPatternItemList() {
    return transitPatternItemList;
}
 
Example #18
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 4 votes vote down vote up
public List<PatternItem> getPatternItemList() {
    return patternItemList;
}
 
Example #19
Source File: DirectionConverter.java    From GoogleDirectionLibrary with Apache License 2.0 4 votes vote down vote up
/**
 * Convert the list of latitude and longitude to the polyline options in transit mode.
 *
 * @param context                A context.
 * @param stepList               A list of latitude and longitude for the steps.
 * @param transitWidth           Width of the polyline in screen pixels for transit polyline.
 * @param transitColor           Color of the polyline as a 32-bit ARGB color for transit polyline.
 * @param transitPatternItemList Stroke pattern for the polyline for transit polyline.
 * @param walkingWidth           Width of the polyline in screen pixels for walking polyline.
 * @param walkingColor           Color of the polyline as a 32-bit ARGB color for walking polyline.
 * @param walkingPatternItemList Stroke pattern for the polyline for walking polyline.
 * @param clickable              Is polyline clickable.
 * @param jointType              Joint type for all vertices of the polyline except the start and end vertices.
 * @param startCap               Cap at the start vertex of the polyline.
 * @param endCap                 Cap at the end vertex of the polyline.
 * @return Options for a polyline.
 * @since 1.2.0
 */
public static ArrayList<PolylineOptions> createTransitPolyline(
        @NonNull Context context,
        @Nullable List<Step> stepList,
        @Dimension(unit = Dimension.DP) int transitWidth,
        @ColorInt int transitColor,
        @Nullable List<PatternItem> transitPatternItemList,
        @Dimension(unit = Dimension.DP) int walkingWidth,
        @ColorInt int walkingColor,
        @Nullable List<PatternItem> walkingPatternItemList,
        boolean clickable,
        int jointType,
        @Nullable Cap startCap,
        @Nullable Cap endCap
) {
    ArrayList<PolylineOptions> polylineOptionsList = new ArrayList<>();
    if (stepList != null && stepList.size() > 0) {
        for (Step step : stepList) {
            ArrayList<LatLng> directionPointList = new ArrayList<>();
            convertStepToPosition(step, directionPointList);
            if (step.isContainStepList()) {
                polylineOptionsList.add(createPolyline(
                        context,
                        directionPointList,
                        walkingWidth,
                        walkingColor,
                        clickable,
                        jointType,
                        startCap,
                        endCap,
                        walkingPatternItemList
                ));
            } else {
                polylineOptionsList.add(createPolyline(
                        context,
                        directionPointList,
                        transitWidth,
                        transitColor,
                        clickable,
                        jointType,
                        startCap,
                        endCap,
                        transitPatternItemList
                ));
            }
        }
    }
    return polylineOptionsList;
}
 
Example #20
Source File: CurveOptions.java    From Curve-Fit with Apache License 2.0 4 votes vote down vote up
public List<PatternItem> getPattern() {
    return real.getPattern();
}
 
Example #21
Source File: DelegatingCurve.java    From Curve-Fit with Apache License 2.0 4 votes vote down vote up
@Override
public void setPattern(List<PatternItem> pattern) {
    polyline.setPattern(pattern);
}
 
Example #22
Source File: DelegatingCurve.java    From Curve-Fit with Apache License 2.0 4 votes vote down vote up
@Override
public List<PatternItem> getPattern() {
    return polyline.getPattern();
}
 
Example #23
Source File: FirstExampleActivity.java    From Curve-Fit with Apache License 2.0 4 votes vote down vote up
private void drawCurveLine() {
    String sourceLatitude = latitudeInputOneEditText.getText().toString().trim();
    String sourceLongitude = longitudeInputOneEditText.getText().toString().trim();
    String destLatitude = latitudeInputTwoEditText.getText().toString().trim();
    String destLongitude = longitudeInputTwoEditText.getText().toString().trim();
    String alpha = alphaEditText.getText().toString().trim();
    if (sourceLatitude.equals("") || sourceLongitude.equals("")
            || destLatitude.equals("") || destLongitude.equals("") || alpha.equals("")) {
        return;
    }

    LatLng initLatLng = new LatLng(Double.valueOf(sourceLatitude), Double.valueOf(sourceLongitude));
    LatLng finalLatLng = new LatLng(Double.valueOf(destLatitude), Double.valueOf(destLongitude));
    CurveOptions curveOptions = new CurveOptions();
    curveOptions.add(initLatLng);
    curveOptions.add(finalLatLng);
    curveOptions.clickable(true);
    curveOptions.setComputePointsBasedOnScreenPixels(checkBox.isChecked());
    curveOptions.setZoomToPosition(true);
    curveOptions.setAlpha(Float.valueOf(alpha));
    curveOptions.width(12);
    List<PatternItem> pattern = Arrays.asList(new Dash(30), new Gap(25));
    curveOptions.pattern(pattern);
    curveOptions.geodesic(false);
    if (checkBox.isChecked()) {
        curveOptions.color(getResources().getColor(R.color.red_500));
    } else {
        curveOptions.color(getResources().getColor(R.color.indigo_a700));
    }

    LatLngBounds.Builder builder = new LatLngBounds.Builder();
    builder.include(initLatLng);
    builder.include(finalLatLng);
    LatLngBounds bounds = builder.build();
    map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 20));

    if (curveManager != null) {
        curveManager.drawCurveAsync(curveOptions);
    }

    map.addMarker(new MarkerOptions().position(initLatLng).anchor(0.5f, 1f));
    map.addMarker(new MarkerOptions().position(finalLatLng)
            .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN))
            .anchor(0.5f, 1f));
}
 
Example #24
Source File: GeoJsonLineStringStyle.java    From android-maps-utils with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the pattern of the GeoJsonLineString
 *
 * @return line style of GeoJsonLineString
 */
public List<PatternItem> getPattern() {
    return mPolylineOptions.getPattern();
}
 
Example #25
Source File: GeoJsonLineStringStyle.java    From android-maps-utils with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the pattern of the GeoJsonLineString
 *
 * @param pattern line style of GeoJsonLineString
 */
public void setPattern(List<PatternItem> pattern) {
    mPolylineOptions.pattern(pattern);
    styleChanged();
}
 
Example #26
Source File: GeoJsonPolygonStyle.java    From android-maps-utils with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the stroke pattern of the GeoJsonPolygon as a list of pattern items
 *
 * @return stroke pattern of the GeoJsonPolygon
 */
public List<PatternItem> getStrokePattern() {
    return mPolygonOptions.getStrokePattern();
}
 
Example #27
Source File: GeoJsonPolygonStyle.java    From android-maps-utils with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the stroke pattern of the GeoJsonPolygon as a list of pattern items
 *
 * @param strokePattern stroke pattern value of the GeoJsonPolygon
 */
public void setStrokePattern(List<PatternItem> strokePattern) {
    mPolygonOptions.strokePattern(strokePattern);
    styleChanged();
}
 
Example #28
Source File: Curve.java    From Curve-Fit with Apache License 2.0 votes vote down vote up
void setPattern(List<PatternItem> pattern); 
Example #29
Source File: Curve.java    From Curve-Fit with Apache License 2.0 votes vote down vote up
List<PatternItem> getPattern();