admin管理员组

文章数量:1278947

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.

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

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.

Share Improve this question asked Mar 13, 2014 at 8:29 Ankit AggarwalAnkit Aggarwal 7871 gold badge9 silver badges15 bronze badges 2
  • possible duplicate of Offline World Satellite Map Without Labels(Android). Also don't notify people in order to get your question visibility (I'm pretty sure its not allowed and/or considered bad behavior). – user180100 Commented Mar 13, 2014 at 14:34
  • @RC. The question you are referring to, does not have an accepted answer. If I could be helped out here. Sorry, for the notification. – Ankit Aggarwal Commented Mar 13, 2014 at 15:36
Add a ment  | 

3 Answers 3

Reset to default 9

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 found an answer, and would love to help anyone who es 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./p/osmdroid/ for the procedure to implement this.

Hope it helps!

Your best option might be to use a different map type. I assume you're using the default MAP_TYPE_NORMAL. This can be changed after the map has been created (i.e. in the onMapReady method by using the mMap.setMapType(...) method). Here are some possibilities:

MAP_TYPE_NORMAL + Custom Map Style

You can easily create your own map styles by using the Styling Wizard. It allows you to create a style that excludes labels entirely (among other things). Once you've created a style you like, you can copy the JSON code generated by that website and add it to the project file res/raw/style_json.json. It can then be applied like this:

mMap.setMapType( GoogleMap.MAP_TYPE_NORMAL );

try
{
    boolean success = mMap.setMapStyle(
            MapStyleOptions.loadRawResourceStyle(
                    getContext(), R.raw.style_json ) );

    if( !success )
    {
        Log.e( TAG, "Style parsing failed." );
    }
}
catch( Resources.NotFoundException e )
{
    Log.e( TAG, "Can't find style. Error: ", e );
}

MAP_TYPE_NONE + Custom Map Tiles

You could add a TileOverlay of non-Google map tiles (like those provided by OpenStreetMap). You would have to find a set that does not include labels within the tiles themselves.

Map Types Without Labels

MAP_TYPE_SATELLITE and MAP_TYPE_NONE don't include labels. However, it sounds like MAP_TYPE_NONE would not be useful for your application by itself.

本文标签: javascriptAndroid Google Maps Hiding labels and showing markersStack Overflow