查询maps.googleapis

时间:2015-10-10 09:09:57

标签: java android google-maps maps

我正在开发使用Google地图的Android应用程序。 我找到了用户,我想通过查询maps.googleapis来显示附近的POI。 在我的java代码中,我有一个与HttpRequest一起使用的String来获取所有信息。字符串是:

"https://maps.googleapis.com/maps/api/place/nearbysearch/" +
                "json?location="+lat+","+lng+
                "&radius=1000&sensor=true" +
                "&types=food|bar|store|museum|art_gallery"+
                "&key=myKey";

其中lat和lng是两个包含用户位置坐标的变量,myKey是我的API密钥。 当我在日志部分启动我的应用程序时,我在索引125"中获取"查询中的非法字符。并且在地图中我没有获得POI。 但如果我删除所有"字符串中的+和字符,我使用浏览器中的链接获取POI列表。 如何在我的应用程序中获取此列表?我不明白我的字符串中的错误在哪里.. 全部

1 个答案:

答案 0 :(得分:0)

根据this link'|'字符应替换为'%7C'

你可以像这样使用

String url=""https://maps.googleapis.com/maps/api/place/nearbysearch/" +
                "json?location="+lat+","+lng+
                "&radius=1000&sensor=true" +
                "&types=food|bar|store|museum|art_gallery"+
                "&key=myKey";";
url.replaceAll(" ","%20");