Google 地图未显示所有地点
Google map not show all places
我将 google 地图集成到我的应用程序中。但是有些地方没有显示出来。我认为事实是地图没有显示购物中心内的商店等。我检查了凭据,但一切都已启用。我以为问题出在这个方法 mGoogleMap.setIndoorEnabled()
但是当我设置值 true
时我没有得到任何效果。
附上 2 个屏幕截图(在网络浏览器中一切正常,在 ios 应用程序和 google 地图中也一切正常):
可能是什么问题?
确实GoogleMap
对象默认不显示所有位置。似乎您应该使用 Place Search from Google Places API 并通过附近的 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>
解析它并以编程方式在地图上显示所需的位置。
注意! Nearby URL request returns only 20 places, load more data you should use string value from next_page_token
tag of response and pass it via pagetoken
parameter for next request:
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 标记之前,您可能需要隐藏 "standard" 个标记,例如 answer of Jozef:
You can do it simply by modification of the map style: Adding a
Styled
Map
- Create JSON file src\main\res\raw\map_style.json like this:
[
{
featureType: "poi",
elementType: "labels",
stylers: [
{
visibility: "off"
}
]
}
]
- Add map style to your
GoogleMap
googleMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(getContext(), R.raw.map_style));
并且不要忘记从 Console.
为您的应用程序启用 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
显示与网络浏览器相同的兴趣点。
我将 google 地图集成到我的应用程序中。但是有些地方没有显示出来。我认为事实是地图没有显示购物中心内的商店等。我检查了凭据,但一切都已启用。我以为问题出在这个方法 mGoogleMap.setIndoorEnabled()
但是当我设置值 true
时我没有得到任何效果。
附上 2 个屏幕截图(在网络浏览器中一切正常,在 ios 应用程序和 google 地图中也一切正常):
可能是什么问题?
确实GoogleMap
对象默认不显示所有位置。似乎您应该使用 Place Search from Google Places API 并通过附近的 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>
解析它并以编程方式在地图上显示所需的位置。
注意! Nearby URL request returns only 20 places, load more data you should use string value from next_page_token
tag of response and pass it via pagetoken
parameter for next request:
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 标记之前,您可能需要隐藏 "standard" 个标记,例如
You can do it simply by modification of the map style: Adding a Styled Map
- Create JSON file src\main\res\raw\map_style.json like this:
[ { featureType: "poi", elementType: "labels", stylers: [ { visibility: "off" } ] } ]
- Add map style to your
GoogleMap
googleMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(getContext(), R.raw.map_style));
并且不要忘记从 Console.
为您的应用程序启用 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
显示与网络浏览器相同的兴趣点。