Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中本地化谷歌地图,并使搜索URL接受另一种语言的参数_Android_Google Maps_Google Api_Localization - Fatal编程技术网

如何在android中本地化谷歌地图,并使搜索URL接受另一种语言的参数

如何在android中本地化谷歌地图,并使搜索URL接受另一种语言的参数,android,google-maps,google-api,localization,Android,Google Maps,Google Api,Localization,我在我的应用程序上创建了一个由谷歌提供支持的自动完成分段搜索,它实现了所有谷歌地图api 我目前居住在塞浦路斯,我想测试我的应用程序。我的问题是,每当我发送requestURL时,由于语言差异,我都会得到wierd编码。我所在的国家的地址是土耳其语而非英语,当我请求URL时,JSON返回一个致命的异常,我的应用程序由于这种奇怪的编码而崩溃: 我怎样才能解决这个问题?:) 也许是一种让requestURL以土耳其语发送的方法 非常感谢各位,你们是最棒的 首先,我的方法是: String reque

我在我的应用程序上创建了一个由谷歌提供支持的自动完成分段搜索,它实现了所有谷歌地图api

我目前居住在塞浦路斯,我想测试我的应用程序。我的问题是,每当我发送requestURL时,由于语言差异,我都会得到wierd编码。我所在的国家的地址是土耳其语而非英语,当我请求URL时,JSON返回一个致命的异常,我的应用程序由于这种奇怪的编码而崩溃:

我怎样才能解决这个问题?:) 也许是一种让requestURL以土耳其语发送的方法

非常感谢各位,你们是最棒的

首先,我的方法是:

String requestApi = null;
    try {
        requestApi = "https://maps.googleapis.com/maps/api/directions/json?" +
                "mode=driving&" +
                "transit_routing_preference=less_driving&" +
                "origin=" + currentPosition.latitude + "," + currentPosition.longitude + "&" +
                "destination=" + destination + "&" + "key=" + getResources().getString(R.string.google_direction_api);
        Log.d("TAG", "Current URL is="+requestApi);
        mService.getPath(requestApi)
                .enqueue(new Callback<String>()
编辑 2018年7月10日

建议的URL编码引发错误,因为google maps不接受编码的URL字符串。我试着用一种方法解码它并消除特殊字符的重复,但这也不起作用

编辑 7/14/2018 我尝试本地化应用程序,并用不同的语言发送目标变量,但仍然出现相同的错误。

应该是解决方法。创建方向API URL时,可以对目标变量的文本进行URL编码:

requestApi = "https://maps.googleapis.com/maps/api/directions/json?" +
            "mode=driving&" +
            "transit_routing_preference=less_driving&" +
            "origin=" + currentPosition.latitude + "," + currentPosition.longitude + "&" +
            "destination=" + URLEncoder.encode(destination, "UTF-8") + "&" + "key=" + getResources().getString(R.string.google_direction_api);

我希望这有帮助

谢谢你,兄弟。但它不起作用,我以前试过:(你找到解决办法了吗
requestApi = "https://maps.googleapis.com/maps/api/directions/json?" +
            "mode=driving&" +
            "transit_routing_preference=less_driving&" +
            "origin=" + currentPosition.latitude + "," + currentPosition.longitude + "&" +
            "destination=" + URLEncoder.encode(destination, "UTF-8") + "&" + "key=" + getResources().getString(R.string.google_direction_api);