0

I've tried to make possible choice on polyline in google maps. But I'm stuck. For example: I have 10 points (with lines).

by using this part of code:

        polylines = new PolylineOptions();
        polylines.color(getResources().getColor(R.color.poly_line_color));

        //add path points, set colour, etc. here
        polyline = mMap.addPolyline(polylines);
        polyline.setPoints(latLngs);
        polyline.setClickable(true);

        mMap.setOnPolylineClickListener(new GoogleMap.OnPolylineClickListener() {
            @Override
            public void onPolylineClick(Polyline polyline) {
                Logger.e("id : "+polyline.getPoints());


            }
        });

we can easy detect click on polyline. But - I can't detect current coordinates (latitude/longitude) for this click.

I tried method

"PolyUtil"

from another library - but this is work randomly and not correct. And really - look like it does not work. 10 clicks on map = 1 good point which is not on polyline or near this line.

Polyline polyline has only few methods and only one normal "getPoints()" but its returned all points.

Can anyone help me with this? I checked a lot of posts on SO but none helped me.

Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54
Peter
  • 2,480
  • 6
  • 39
  • 60

1 Answers1

0
   map.setOnPolylineClickListener(new GoogleMap.OnPolylineClickListener() {
     polyline.getPoints()
});

Try this function polyline.getPoints() in your code. This may help you. Thanks

Haseeb Mirza
  • 432
  • 2
  • 7