谷歌地图宫殿颤动



我正在尝试在我的应用程序中获取附近的地点,但有一些错误。

如果有相同的主题,请通知我

我期待您的建议

void _searchNearby(double latitude, double longitude) async {
setState(() {
markers.clear();
});
String url =
'${googlePlaceURL}/json?location=${latitude},${longitude}&radius=1500&type=${placeType}&key=${mapAPI}';
print(url);
http.Response response = await http.get(url);
print('********'+'$response');
if (response.statusCode == 200) {
final data = json.decode(response.body);
print(data);
} else {
throw Exception('An error occurred getting places nearby');
}
}

错误:

I/flutter (10208):  https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=37.4219983,-122.084&radius=1500&type=subway_station&key=AIzaSyAjclu-U5mgWji4rENX0LxvrfYXljfK5pg
E/flutter (10208): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FormatException: Scheme not starting with alphabetic character (at character 1)
E/flutter (10208):  https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=37.4...
E/flutter (10208): ^
E/flutter (10208):
E/flutter (10208): #0      _Uri._fail (dart:core/uri.dart:1623:5)
E/flutter (10208): #1      _Uri._makeScheme (dart:core/uri.dart:2184:7)
E/flutter (10208): #2      new _Uri.notSimple (dart:core/uri.dart:1465:18)
E/flutter (10208): #3      Uri.parse (dart:core/uri.dart:1022:17)
E/flutter (10208): #4      BaseClient._sendUnstreamed (package:http/src/base_client.dart:152:34)
E/flutter (10208): <asynchronous suspension>
E/flutter (10208): #5      BaseClient.get (package:http/src/base_client.dart:32:7)
E/flutter (10208): #6      get.<anonymous closure> (package:http/http.dart:46:36)
E/flutter (10208): #7      _withClient (package:http/http.dart:166:20)
E/flutter (10208): <asynchronous suspension>
E/flutter (10208): #8      get (package:http/http.dart:46:5)
E/flutter (10208): #9      MapSampleState._searchNearby (package:flutter_course/Map/map.dart:44:36)
E/flutter (10208): <asynchronous suspension>
E/flutter (10208): #10     MapSampleState.build.<anonymous closure> (package:flutter_course/Map/map.dart:119:11)

看起来变量googlePlaceURL空格开头。看看吧,我认为你可以用一种简单的方式解决它。

相关内容

  • 没有找到相关文章