add method
Adds one marker. iconBytes must contain encoded image bytes such as PNG.
Implementation
Future<MarkerId> add(
GeoPoint position, {
MarkerId? markerId,
Uint8List? iconBytes,
}) async {
if (iconBytes?.isEmpty ?? false) {
throw _argumentException(_controller, 'addMarker', 'empty_icon');
}
final id = markerId ?? _controller._nextMarkerId();
if (!_issuedIds.add(id)) {
throw AndroidMapException(
operation: 'addMarker',
code: 'duplicate_marker_id',
viewId: _controller.viewId,
message: 'Marker ID ${id.value} was already issued by this controller.',
);
}
try {
final transport = await _controller._readyTransport();
await transport.addMarker(id, position, iconBytes: iconBytes);
return id;
} catch (_) {
_issuedIds.remove(id);
rethrow;
}
}