【问题标题】:how do i pass the value of lat and long in "location": "27.6710, 85.4298",我如何在 \"location\" 中传递 lat 和 long 的值: \"27.6710, 85.4298\",
【发布时间】:2023-01-21 17:57:09
【问题描述】:

How do i pass the value of lat and long in "location": "27.6710, 85.4298",

我正在尝试传递 lat 和 long 的值,这给了我用户的当前位置

【问题讨论】:

  • “位置”:“${lat.toString()}, ${long.toString()}”

标签: flutter dart google-maps


【解决方案1】:
List myplacelist = []; 
void getNearbyPlaces() async { 
    _determinePosition().then((value) async {
        double lat = value.latitude; 
        double long = value.longitude; 
        var uri = Uri.https(
            'trueway-places.p.rapidapi.com', 
            '/FindPlacesNearby',
             {
                 "location": lat.toSring() + ", " + long.toSring(), 
                 "type": "restaurant", "radius": "150 ", 
                 "language": "en",
             }
        ); 
        final response = await http.get(
            uri, 
            headers: { 
                "X-RapidAPI-Key": "API Key Here", // <= add your api key
                "X-RapidAPI-Host": "trueway-places.p.rapidapi.com", 
                "useQuerystring": "true", 
            }
        ); 
        Map data = jsonDecode(response.body); 
        myplacelist = data['results']; 
    }); 
} 

笔记 :不要公开分享API Keys

【讨论】:

    猜你喜欢
    • 2021-04-18
    • 2014-12-03
    • 1970-01-01
    • 2021-03-04
    • 2017-07-14
    • 1970-01-01
    • 1970-01-01
    • 2018-05-28
    • 1970-01-01
    相关资源
    最近更新 更多