|
| 1 | +// Copyright 2024 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package com.google.maps.example; |
| 16 | + |
| 17 | +import android.graphics.Color; |
| 18 | + |
| 19 | +import androidx.appcompat.app.AppCompatActivity; |
| 20 | + |
| 21 | +import com.google.android.gms.maps.GoogleMap; |
| 22 | +import com.google.android.gms.maps.model.BitmapDescriptorFactory; |
| 23 | +import com.google.android.gms.maps.model.LatLng; |
| 24 | +import com.google.android.gms.maps.model.Polyline; |
| 25 | +import com.google.android.gms.maps.model.PolylineOptions; |
| 26 | +import com.google.android.gms.maps.model.StampStyle; |
| 27 | +import com.google.android.gms.maps.model.StrokeStyle; |
| 28 | +import com.google.android.gms.maps.model.StyleSpan; |
| 29 | +import com.google.android.gms.maps.model.TextureStyle; |
| 30 | + |
| 31 | +public class PolylineCustomizationActivity extends AppCompatActivity { |
| 32 | + |
| 33 | + private GoogleMap map; |
| 34 | + |
| 35 | + private void multicoloredPolyline() { |
| 36 | + // [START maps_android_polyline_multicolored] |
| 37 | + Polyline line = map.addPolyline(new PolylineOptions() |
| 38 | + .add(new LatLng(47.6677146,-122.3470447), new LatLng(47.6442757,-122.2814693)) |
| 39 | + .addSpan(new StyleSpan(Color.RED)) |
| 40 | + .addSpan(new StyleSpan(Color.GREEN))); |
| 41 | + // [END maps_android_polyline_multicolored] |
| 42 | + } |
| 43 | + |
| 44 | + private void multicoloredGradientPolyline() { |
| 45 | + // [START maps_android_polyline_gradient] |
| 46 | + Polyline line = map.addPolyline(new PolylineOptions() |
| 47 | + .add(new LatLng(47.6677146,-122.3470447), new LatLng(47.6442757,-122.2814693)) |
| 48 | + .addSpan(new StyleSpan(StrokeStyle.gradientBuilder(Color.RED, Color.YELLOW).build()))); |
| 49 | + // [END maps_android_polyline_gradient] |
| 50 | + } |
| 51 | + |
| 52 | + private void stampedPolyline() { |
| 53 | + // [START maps_android_polyline_stamped] |
| 54 | + StampStyle stampStyle = |
| 55 | + TextureStyle.newBuilder(BitmapDescriptorFactory.fromResource(R.drawable.walking_dot)).build(); |
| 56 | + StyleSpan span = new StyleSpan(StrokeStyle.colorBuilder(Color.RED).stamp(stampStyle).build()); |
| 57 | + map.addPolyline(new PolylineOptions() |
| 58 | + .add(new LatLng(47.6677146,-122.3470447), new LatLng(47.6442757,-122.2814693)) |
| 59 | + .addSpan(span)); |
| 60 | + // [END maps_android_polyline_stamped] |
| 61 | + } |
| 62 | +} |
0 commit comments