简体   繁体   中英

Android Google Maps: Hiding labels and showing markers

I want to develop an Android application where I present users with a map with some markers. On the basis of a question they select a marker which is then evaluated as correct or wrong. Now the problems:

This can be implemented with Google Maps Android API v2 :

  1. But problem is that I am not able to hide country, state or continent names. That takes away the purpose of the game. Can I blur out the names? Can I prevent zoom?

Using WebViews and Google Maps in WebView :

  1. Problem is that markers cannot be made clickable for this. How can I do this. Plus where is javascript coding done? Could I have tutorials for this?

Using offline maps.

Is that a possibility. Can I put markers on it, and know where user clicked?

The application "Geography Learning Game" does it nicely, and it also has Google written at the bottom, so they are using Google maps only. http://goo.gl/obE1fB

Answering any of the above will solve my problem. Please reply with code.

I found an answer, and would love to help anyone who comes across this while browsing.

Country, continent etc names can't be hidden using Google Maps, so OpenStreetMaps overlay layer is to be used over Google Maps.

So rest of the code remains same, just add an overlay. This selectively hides what has to be hidden.

Refer to https://code.google.com/p/osmdroid/ for the procedure to implement this.

Hope it helps!

You can customize your map by applying map style using GoogleMap.setMapStyle(MapStyleOptions) (method reference) . You can create map style here (just move 'labels' progress bar to customize map labels). Copy map style json and create raw resource with its content.

Your onMapReady will look like this:

override fun onMapReady(googleMap: GoogleMap) {
    try {
        googleMap.setMapStyle(
                MapStyleOptions.loadRawResourceStyle(context, R.raw.map_without_labels_style)
        )
    } catch (e: Resources.NotFoundException) {
        // log it
    }
}

More information could be found here

I'm not 100% sure but the app you referenced might be using Google Enterprise maps. You will have to look into that here http://www.google.com/enterprise/mapsearth/ .

However you might be able to set the map type to satellite to remove labels. I don't know any clear way to blur the map labels.

googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);

To Disable Zoom you can do the following.

googleMap.getUiSettings().setZoomControlsEnabled(false);
googleMap.getUiSettings().setZoomGesturesEnabled(false);

As for the webview someone else will need to answer that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM