Closed jdevo2004 closed 11 months ago
Hello @jdevo2004
Yes, as seen on example, you can add tags to your polylines then open a popup (have a look at https://api.flutter.dev/flutter/material/showDialog.html):
TappablePolylineLayer(
// Will only render visible polylines, increasing performance
polylineCulling: true,
pointerDistanceTolerance: 20,
polylines: [
TaggedPolyline(
tag: 'My Polyline',
// An optional tag to distinguish polylines in callback
points: getPoints(0),
color: Colors.red,
strokeWidth: 9.0,
),
TaggedPolyline(
tag: 'My 2nd Polyline',
// An optional tag to distinguish polylines in callback
points: getPoints(1),
color: Colors.black,
strokeWidth: 3.0,
),
TaggedPolyline(
tag: 'My 3rd Polyline',
// An optional tag to distinguish polylines in callback
points: getPoints(0),
color: Colors.blue,
strokeWidth: 3.0,
),
],
// you have to change here so you open dialog when one polyline has been tapped
onTap: (polylines, tapPosition) => print('Tapped: ' +
polylines.map((polyline) => polyline.tag).join(',') +
' at ' +
tapPosition.globalPosition.toString()),
onMiss: (tapPosition) {
print('No polyline was tapped at position ' +
tapPosition.globalPosition.toString());
})
Is there a way to detect which polyline from a list was tapped and open a popup window?