谷歌地图未显示所有地点

4
我将Google地图集成到我的应用程序中,但是一些地方没有显示在地图上。我认为这是因为地图并没有显示购物中心内部等商店。我检查了凭据,但是所有内容都已启用。我认为问题出在这个方法 mGoogleMap.setIndoorEnabled() 上,但是当我将值设置为true时,没有任何效果。
附上两张截图(在Web浏览器中和带有Google地图的iOS应用程序中都正常): 无法显示所有地点的屏幕截图1 显示所有地点的屏幕截图2 可能的问题是什么?
1个回答

2

实际上,默认情况下,GoogleMap对象并不会显示所有地点。看起来您应该使用Google Places API中的Place Search,通过附近的URL请求获取兴趣点列表:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=<LAT_LNG_e_g_ 32.944552,-97.129767>&types=point_of_interest&radius=<RADIUS_IN_METERS>&sensor=false&key=<YOUR_APP_KEY>

解析它并以编程方式在地图上显示所需位置。
注意!附近的URL请求仅返回20个地点,若需加载更多数据,则应使用响应中的next_page_token标签中的字符串值,并通过pagetoken参数传递到下一个请求。
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=<LAT_LNG_e_g_ 32.944552,-97.129767>&types=point_of_interest&radius=<RADIUS_IN_METERS>&sensor=false&key=<YOUR_APP_KEY>&pagetoken=<TOKEN_FOR_NEXT_PAGE_FROM_next_page_token_TAG_OF_RESPONSE>

在添加兴趣点(POI)的标记之前,您可能需要隐藏“标准”标记,就像Jozef答案中所示:

You can do it simply by modification of the map style: Adding a Styled Map

  1. Create JSON file src\main\res\raw\map_style.json like this:

[
  {
    featureType: "poi",
    elementType: "labels",
    stylers: [
      {
        visibility: "off"
      }
    ]
  }
]
  1. Add map style to your GoogleMap

googleMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(getContext(), R.raw.map_style));

不要忘记从控制台启用Places API,以供应用程序使用。

或者,您可以使用简单的WebView代替MapFragment,并打开所需位置。

WebView webview = (WebView) findViewById(R.id.web_view);
webview.setWebViewClient(new WebViewClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("http://maps.google.com/maps?q=32.944552,-97.129767&z=20");

WebView 显示与 Web 浏览器相同的兴趣点。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接