addPoi method

  1. @override
Future<String> addPoi(
  1. LatLng position, {
  2. required PoiStyle style,
  3. String? id,
  4. String? text,
  5. int? rank,
  6. bool visible = true,
})
override

Implementation

@override
Future<String> addPoi(
  LatLng position, {
  required PoiStyle style,
  String? id,
  String? text,
  int? rank,
  bool visible = true,
}) async {
  final poiId = manager._uuid.v4();

  _preEncodedImage[poiId] = {};
  if (style.icon != null) {
    _preEncodedImage[poiId]![style.zoomLevel] =
        encodeImageToBase64(await style.icon!.readBytes());
  }
  for (var inStyle in style.otherStyles) {
    if (inStyle.icon == null) continue;
    _preEncodedImage[poiId]![inStyle.zoomLevel] =
        encodeImageToBase64(await style.icon!.readBytes());
  }
  final encodedIcon = _preEncodedImage[poiId]?[style.zoomLevel];
  final options = WebCustomOverlayOption(
      clickable: true,
      content: poiElement(poiId, encodedIcon, style.icon, text, style, () {
        manager._onPoiClick(this.id, poiId, isLod);
      }),
      position: WebLatLng.fromLatLng(position),
      xAnchor: style.anchor.x.toDouble(),
      yAnchor: style.anchor.y.toDouble(),
      zIndex: rank ?? 10001);
  _currentPoiLevel[poiId] = style.zoomLevel;
  final overlay = _webPoi[poiId] = WebCustomOverlay(options);
  overlay.setMap(controller);
  overlay.setVisible(visible);
  _poiStyleId[poiId] = style.id!;
  _syncZoomLevel(poiId, style.id!, text);
  return poiId;
}