实际上,默认情况下,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>
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
- 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));
不要忘记从控制台启用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 浏览器相同的兴趣点。