addMarker method
Future<void>
addMarker(
- GeoPoint p, {
- MarkerIcon? markerIcon,
- double? angle,
- IconAnchor? iconAnchor,
create marker int specific position without
change map camera,
you can rotate marker using angle
and also set marker anchor using iconAnchor
p
: (GeoPoint) desired location
markerIcon
: (MarkerIcon) set icon of the marker
Implementation
@override
Future<void> addMarker(
GeoPoint p, {
MarkerIcon? markerIcon,
double? angle,
IconAnchor? iconAnchor,
}) async {
Widget? icon = markerIcon;
if (icon == null) {
icon = Icon(
Icons.location_on,
size: 32,
color: Colors.red,
);
}
osmWebFlutterState.widget.dynamicMarkerWidgetNotifier.value = icon;
await Future.delayed(duration, () async {
final icon = await capturePng(osmWebFlutterState.dynamicMarkerKey!);
var sizeIcon = osmWebFlutterState.dynamicMarkerKey!.currentContext?.size;
var anchor = null;
if (iconAnchor != null) {
anchor = iconAnchor.toAnchorJS;
}
interop.addMarker(
mapIdMixin,
p.toGeoJS(),
sizeIcon.toSizeJS(),
icon.convertToString(),
angle != null ? (angle * (180 / pi)) : 0,
anchor,
);
});
}