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();

  final Map<int, String> preEncodedImage = {};
  if (style.icon != null) {
    preEncodedImage[style.zoomLevel] =
        encodeImageToBase64(await style.icon!.readBytes());
  }
  for (var inStyle in style.otherStyles) {
    if (inStyle.icon == null) continue;
    preEncodedImage[inStyle.zoomLevel] =
        encodeImageToBase64(await inStyle.icon!.readBytes());
  }

  final poi = _webPoi[poiId] = WebPoi(poiId, this.id,
      currentLevel: style.zoomLevel,
      text: text,
      styleId: style.id!, onClick: () {
    manager._onPoiClick(this.id, poiId, isLod);
  });

  final options = WebCustomOverlayOption(
      clickable: true,
      content: poiElement(poi, style),
      position: WebLatLng.fromLatLng(position),
      xAnchor: style.anchor.x.toDouble(),
      yAnchor: style.anchor.y.toDouble(),
      zIndex: rank ?? 10001);
  poi.overlay = WebCustomOverlay(options);
  poi.preEncodedImage.addAll(preEncodedImage);

  poi.setMap(controller);
  poi.setVisible(visible);

  _syncZoomLevel(poiId);
  return poiId;
}