Git Product home page Git Product logo

Comments (3)

kikoso avatar kikoso commented on June 4, 2024

Hi @mintheinwin ,

You are setting a single polyline. Could you try adding a polyline from A to B with a given color, and then another polyline from B to C with a different color?

from android-samples.

mintheinwin avatar mintheinwin commented on June 4, 2024

Hi @kikoso , Yes I had tried like that. I have solve my problem.

public ArrayList list = new ArrayList();

getPermissionAndLocationChange(list);

    private void getPermissionAndLocationChange(final ArrayList<LatLng> tList) {
    locationCallback = new LocationCallback() {
        //This callback is where we get "streaming" location updates. We can check things like accuracy to determine whether
        //this latest update should replace our previous estimate.
        @Override
        public void onLocationResult(LocationResult locationResult) {
            if (locationResult == null) {
                Log.d(TAG, "locationResult null");
                return;
            }
            Log.d(TAG, "received " + locationResult.getLocations().size() + " locations");
            for (Location loc : locationResult.getLocations()) {
                tList.add(new LatLng(loc.getLatitude(), loc.getLongitude()));

                //StampStyle stampStyle = TextureStyle.newBuilder(BitmapDescriptorFactory.fromResource(R.drawable.ic_arrow)).build();
                if (colorStart == 0) {
                    styleSpanArrayList.add(new StyleSpan(StrokeStyle.colorBuilder(Color.GREEN).build()));
                    colorStart = 1;
                } else if (colorStart == 1) {
                    styleSpanArrayList.add(new StyleSpan(StrokeStyle.colorBuilder(Color.YELLOW).build()));
                    colorStart = 2;
                } else if (colorStart == 2) {
                    styleSpanArrayList.add(new StyleSpan(StrokeStyle.colorBuilder(Color.RED).build()));
                    colorStart = 0;
                }
                if (line!=null)line.remove();
                line = map.addPolyline(new PolylineOptions().addAll(tList).width(30).addAllSpans(styleSpanArrayList));

               /* tList.add(new LatLng(1.4384168567466844, 103.80680969583258));
                styleSpanArrayList.add(new StyleSpan(StrokeStyle.colorBuilder(Color.GREEN).build()));
                tList.add(new LatLng(1.4393477524038727, 103.80260854186459));
                styleSpanArrayList.add(new StyleSpan(StrokeStyle.colorBuilder(Color.YELLOW).build()));
                tList.add(new LatLng(1.4408750600926357, 103.80097019583253));
                styleSpanArrayList.add(new StyleSpan(StrokeStyle.colorBuilder(Color.RED).build()));

                Polyline line = map.addPolyline(new PolylineOptions().addAll(tList).width(30).addAllSpans(styleSpanArrayList));*/

            }
        }

        @Override
        public void onLocationAvailability(LocationAvailability locationAvailability) {
            Log.d(TAG, "locationAvailability is " + locationAvailability.isLocationAvailable());
            super.onLocationAvailability(locationAvailability);
        }
    };

}

from android-samples.

kikoso avatar kikoso commented on June 4, 2024

Great to know! Thanks for letting us know, @mintheinwin

from android-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.