【问题标题】:google map palace flutter谷歌地图宫扑
【发布时间】:2020-01-16 17:58:09
【问题描述】:

我正在尝试在我的应用中获取附近的地点,但出现了一些错误。

如果有相同的话题请关注我

期待你的建议

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)

【问题讨论】:

标签: google-maps flutter google-places-api


【解决方案1】:

看起来变量googlePlaceURL 以空格开头。看看吧,我想你可以很容易地解决它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多