我想通过从mapbox调用API来获取静态图像,但它返回了以下消息:
{"message":"Failed parsing geojson"} // with status code:422我使用mapbox_search包创建了该接口。这是我的代码:
MapBoxStaticImage staticImage = MapBoxStaticImage(
apiKey:
    'pk.eyJ1IjoiYXNocmFmaWowMDciLCJhIjoiY2s2Nm40ZjFkMDAxMDNubXo3M3V4Y2pvaiJ9.cQACwGfCXD1iuKdJeZDozA',
);
Future<String> getStaticImageWithMarker() async {
final locationData = await locationFinder.Location().getLocation();
return staticImage.getStaticUrlWithMarker(
  center: Location(lat: locationData.latitude, lng: locationData.longitude),
  marker: MapBoxMarker(
      markerColor: Color.rgb(200, 0, 0),
      markerLetter: 'p',
      markerSize: MarkerSize.LARGE),
  height: 300,
  width: 600,
  zoomLevel: 16,
  style: MapBoxStyle.Streets,
  render2x: true,
);
}getStaticImageWithMarker()函数返回这个用于创建图像的接口,但是我得到了我在顶部提到的错误。
https://api.mapbox.com/styles/v1/mapbox/streets-v11/static/pin-l-p+c800(-122.084,37.4219983)/-122.084,37.4219983,16,0,20/600x300@2x?access_token=pk.eyJ1IjoiYXNocmFmaWowMDciLCJhIjoiY2s2Nm40ZjFkMDAxMDNubXo3M3V4Y2pvaiJ9.cQACwGfCXD1iuKdJeZDozA有没有人知道我在这个APIcalling中做错了什么?
发布于 2021-04-23 20:15:43
在mapbox中,我得到了“无效的图像”错误。然后我选择了Mapbox样式的Carto来修复它。
发布于 2021-01-14 17:28:18
我创建了一个获取经度和纬度的函数,并从mapbox返回图像的链接:
String getStaticImageWithMarker(double latitude, double longitude) {
return 'https://api.mapbox.com/styles/v1/mapbox/streets-v11/static/' +
    'geojson(%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B$longitude%2C$latitude%5D%7D)/$longitude,$latitude,16/500x300?' +
    'access_token=your token from mapbox';
}之后,你可以使用web上的图像框来获取地点图像。
发布于 2021-01-23 17:05:34
这就是MapBox解释如何使用Jafar在他的回答中描述的链接的地方,他的回答对我有效。
文档中的示例:
/styles/v1/{username}/{style_id}/static/{overlay}/{lon},{纬度},{缩放},{方位},{间距}|{bbox}|{自动}/{宽度}x{高度}{@2x}
返回链接后,在Image.network小部件中使用它,如下所示:
Image.network('${getStaticImageWithMarker(routeLat,routeLong)}'),
https://stackoverflow.com/questions/60494476
复制相似问题