0

How I can have InfoWindow for my route drive on my map like google map app :

enter image description here

I am trying to create like this :

googleMaps.setOnPolylineClickListener(new GoogleMap.OnPolylineClickListener() {
    @Override
    public void onPolylineClick(Polyline polyline) {
        for (LatLng pathCoordinates : polyline.getPoints()) {
            googleMaps.getProjection().toScreenLocation(pathCoordinates);
            Double A = pathCoordinates.latitude;
            Double B = pathCoordinates.longitude;
            MarkerOptions markerOptions = new MarkerOptions();
            markerOptions.position(new LatLng(A, B));
            Marker marker = googleMaps.addMarker(markerOptions);
            marker.showInfoWindow();
        }
    }
});

But show me :

enter image description here

How I can manage my code ?

1 Answers1

0

According to docs you can't have more than one info window at a time. So you can't use it.

What you could do is create custom markers, one for each line. You could calculate their position/rotation/etc using the information from polylines.

Unfortunately, markers can't be customized extensively. Google doesn't offer this possibility yet. From the docs you can see that there isn't a "clear" way to add text. However, you can change the image generating a bitmap and according to this you could add text on the bitmap using the Canvas.

Community
  • 1
  • 1
masp
  • 515
  • 1
  • 5
  • 15