Remove Google Maps options

I am using Google Maps and would like to take away all other options (restaurants, churches, schools, posts, etc.) and leave only my bookmarks

I currently start the map like this:

function initMap( lat, lng, nome, lojas  ) {
        var myLatLng = {lat, lng};
        var map = new google.maps.Map(document.getElementById('map'), {
          zoom: 16,
          center: myLatLng
        });

        var marker = new google.maps.Marker({
          position: myLatLng,
          map: map,
          title: nome
        });
     }

insert the description of the image here

Author: adventistaam, 2019-08-02

1 answers

Try adding this:

var styles = {
    default: null,
    hide: [
      {
        featureType: 'poi.business',
        stylers: [{visibility: 'off'}]
      },
      {
        featureType: 'transit',
        elementType: 'labels.icon',
        stylers: [{visibility: 'off'}]
      }
    ]
  }; //Aqui você define o estilo na qual os ícones ficam invisíveis

map.setOptions({styles: styles['default']}); //Aqui você aplica o estilo ao seu mapa

Taken from Google's own documentation: https://developers.google.com/maps/documentation/javascript/examples/hiding-features

In your code it would look like this:

var styles = {
        default: null,
        hide: [
            {
            featureType: 'poi.business',
            stylers: [{visibility: 'off'}]
        },
        {
        featureType: 'transit',
        elementType: 'labels.icon',
        stylers: [{visibility: 'off'}]
      }
    ]
  }; 

function initMap( lat, lng, nome, lojas  ) {
    var myLatLng = {lat, lng};
    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 16,
      center: myLatLng
    });

  map.setOptions({styles: styles['hide']});

    var marker = new google.maps.Marker({
      position: myLatLng,
      map: map,
      title: nome
    });
 }

Access all featureType in the following link: https://developers.google.com/maps/documentation/javascript/style-reference#style-features

 1
Author: Leonardo Bonetti, 2019-08-02 17:02:12