4

I integrated the google map to my app. But some places do not show on it. I think the fact is that the map does not show shops inside shopping centers and the like. I checked the Credentials, but there everything is enabled. I thought the matter was in this method mGoogleMap.setIndoorEnabled() but when I set the value true I did not get any effect.

Attached 2 screenshots (in web browser in all ok, also in ios app with google map all ok): screenshot 1 - whithout all places screenshot 1 - with all places

What could be the problem?

1 Answers1

2

Indeed GoogleMap object not show all places by default. Seems you should use Place Search from Google Places API and get list of points of interest via nearby URL 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>

parse it and show desired places on map programmatically.

NB! Nearby URL request returns only 20 places, for 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>

Before add markers of POI may be you need to hide "standard" markers, like in this answer of 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));

And don't forget to enable Places API for your application from Console.

Or, you can do the trick: use simple WebView instead of MapFragment and open it for necessary place:

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 shows same Points of Interest as web browser.

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79