我想通过从 mapbox 调用 API 来获取静态图像,但它返回了这条消息:
{"message":"Failed parsing geojson"} // with status code:422
我使用 mapbox_search 包来创建 API。这是我的代码:
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() 函数返回此 api 用于创建图像,但我得到了我在顶部提到的错误。
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 中做错了什么?