0

I'm working on a college based Android application. I need to create a custom map for college campus and want to replace google's icons and labels with my own. Is there any way to achieve it?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • please read https://stackoverflow.com/questions/14811579/how-to-create-a-custom-shaped-bitmap-marker-with-android-map-api-v2 – jessica Jun 08 '18 at 09:23
  • thanks, @JaspreetKaur. But I don't think that solution removes google's icons and labels. We can add our icons and labels but, I want to show only my labels, not Google's. – Tarun Bhardwaj Jun 08 '18 at 11:09

1 Answers1

1

In order to hide default icons and labels for POIs you have to create a custom styled map. For example the following style is hiding default POIs

[
  {
    "featureType": "poi",
    "elementType": "labels",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  },
  {
    "featureType": "poi",
    "elementType": "labels.icon",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  }
]

You should create a resource file that contains your custom style (e.g. /res/raw/style_json.json) and apply it when your map is loading

public void onMapReady(GoogleMap googleMap) {

    try {
        // Customise the styling of the base map using a JSON object defined
        // in a raw resource file.
        boolean success = googleMap.setMapStyle(
                MapStyleOptions.loadRawResourceStyle(
                        this, 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);
    }
    // Position the map's camera near Sydney, Australia.
    googleMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(-34, 151)));
}

For detailed information please follow the tutorial:

Adding a Styled Map

To create your own markers you should follow

Markers

I hope this helps!

xomena
  • 31,125
  • 6
  • 88
  • 117