-
-
Notifications
You must be signed in to change notification settings - Fork 855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pop up on marker clicked #184
Comments
+1 for me |
As a workaround, are you able to do this as part of your Marker widget? |
@johnpryan marker widget don't have such option which supports pop up |
Can't you do something like have a marker with a GestureDetector and then pop up a card or something when onTap is registered ? |
In google maps this is called a Marker InfoWindow - I think that it is typically implemented using a marker adapter. This is probably something that we would have to add support for by submitting a PR if no one else is working on it. |
We don’t plan to add support for this directly to the map because i think it can be implemented using @ibrierly’s suggestion |
@dazza5000 It would be great if you submit a PR for this feature I need it in my project asap thanks |
@ibrierley can you please provide an example for your solution? sorry I am new to flutter I couldn't understand your solution correctly. |
@DanialV You might be able to use https://docs.flutter.io/flutter/material/DropdownMenuItem-class.html in the Marker |
This is a bit of quick code to highlight what I mean...it will need some tweaking, change centerlatlng to be wherever the original marker is in latlng
Then in build function somewhere...
|
another way ...
return Marker(
width: 40.0,
height: 40.0,
point: LatLng(latLong[0], latLong[1]),
builder: (ctx) => MapMarker(x),
);
});
}
class MapMarker extends StatefulWidget {
final X x;
MapMarker(this.x);
@override
_MapMarkerState createState() => _MapMarkerState();
}
class _MapMarkerState extends State<MapMarker> {
final key = new GlobalKey();
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
final dynamic tooltip = key.currentState;
tooltip.ensureTooltipVisible();
},
child: Tooltip(
key: key,
message: widget.x.name,
textStyle: textStyle,
padding: EdgeInsets.fromLTRB(10, 10, 10, 15),
decoration: BoxDecoration(
color: Colors.white,
),
child: Container(
child: SvgPicture.asset(
'assets/svg/map_mark_green_icon.svg',
),
),
),
);
}
} |
what is X? |
@klaszlo8207 |
Here is my drop-in widget created with the previous answers (thanks!). Simply pass your existing marker child as the widgetclass MarkerWithTooltip extends StatefulWidget {
final Widget child;
final String tooltip;
final Function onTap;
MarkerWithTooltip({@required this.child, this.tooltip, this.onTap});
@override
_MapMarkerState createState() => _MapMarkerState();
}
class _MapMarkerState extends State<MarkerWithTooltip> {
final key = new GlobalKey();
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
final dynamic tooltip = key.currentState;
tooltip.ensureTooltipVisible();
widget.onTap();
},
child: Tooltip(
key: key,
message: widget.tooltip,
child: widget.child,
));
}
} useMarker(
point: // the position
builder: (BuildContext context) {
return MarkerWithTooltip(
child: Image.asset(
'marker.png'),
tooltip: "the tooltip text",
onTap: onTap);
}); |
Thank you. Worked really well for me. Additional notes : you have to place the MarkerLayer() at the very last of FlutterMap children. For example, this one will work :
While this one will not work :
Likely because the tap event only enters the topmost layer. |
Does the solution(s) here still work? I am trying this with the latest copy of this repository in the Marker signature now const Marker({
this.key,
required this.point,
required this.child,
this.width = 30,
this.height = 30,
this.alignment,
this.rotate,
}); |
Just use |
Yes, that worked for me for the |
I want to have pop up on marker clicked like simple map example of leafletjs site but however I couldn't find such feature
here is js code provided in leaflet website:
The text was updated successfully, but these errors were encountered: