MapBox 搜索和静态图像纯 Dart 实现

用于使用 MapBox API 进行地点搜索和静态地图图像的 Flutter 包
我制作这个包是因为谷歌地点搜索效率不高(每日配额限制),而 MapBox 提供了大量的免费搜索请求。

如果你想要静态地图图像,它比谷歌更有用。

安装

将以下内容添加到您的 pubspec.yaml 文件中

dependencies:
  mapbox_search: any

示例

静态图像

MapBoxStaticImage staticImage = MapBoxStaticImage(
    apiKey:
        "API Key");

带有折线的图像

String getStaticImageWithPolyline() => staticImage.getStaticUrlWithPolyline(
  point1: Location(lat: 37.77343, lng: -122.46589),
  point2: Location(lat: 37.75965, lng: -122.42816),
  marker1: MapBoxMarker( markerColor: Colors.black, markerLetter: 'p', markerSize: MarkerSize.LARGE),
  msrker2: MapBoxMarker(
      markerColor: Colors.redAccent,
      markerLetter: 'q',
      markerSize: MarkerSize.SMALL),
  height: 300,
  width: 600,
  zoomLevel: 16,
  style: MapBoxStyle.Mapbox_Dark,
  path: MapBoxPath(pathColor: Colors.red, pathOpacity: 0.5,     pathWidth: 5),
  render2x: true);

带有标记的图像

String getStaticImageWithMarker() => staticImage.getStaticUrlWithMarker(
  center: Location(lat: 37.77343, lng: -122.46589),
  marker: MapBoxMarker(
      markerColor: Colors.black, markerLetter: 'p', markerSize: MarkerSize.LARGE),
  height: 300,
  width: 600,
  zoomLevel: 16,
  style: MapBoxStyle.Mapbox_Streets,
  render2x: true,
);

不带标记的图像

String getStaticImageWithoutMarker() => staticImage.getStaticUrlWithoutMarker(
    center: Location(lat: 37.75965, lng: -122.42816),
    height: 300,
    width: 600,
    zoomLevel: 16,
    style: MapBoxStyle.Mapbox_Outdoors,
    render2x: true,
  );

搜索小部件

MapBoxPlaceSearchWidget(
      popOnSelect: true,
      apiKey:
          "API KEY",
      limit: 10,
      onSelected: (place) {},
      context: context,
)

截图

staticImages

search2

search1

GitHub

https://github.com/ketanchoyal/mapbox_search