Google-map-react: Show building name/location name on map

Created on 12 Oct 2016  路  5Comments  路  Source: google-map-react/google-map-react

I need to show building name/location name on map like this

Are there any ways to support this feature?
Thank you.

link

// This example requires the Places library. Include the libraries=places
// parameter when you first load the API. For example:
// <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places">

function initMap() {
  var map = new google.maps.Map(document.getElementById('map'), {
    center: {lat: -33.866, lng: 151.196},
    zoom: 15
  });

  var infowindow = new google.maps.InfoWindow();
  var service = new google.maps.places.PlacesService(map);

  service.getDetails({
    placeId: 'ChIJN1t_tDeuEmsRUsoyG83frY4'
  }, function(place, status) {
    if (status === google.maps.places.PlacesServiceStatus.OK) {
      var marker = new google.maps.Marker({
        map: map,
        position: place.geometry.location
      });
      google.maps.event.addListener(marker, 'click', function() {
        infowindow.setContent('<div><strong>' + place.name + '</strong><br>' +
          'Place ID: ' + place.place_id + '<br>' +
          place.formatted_address + '</div>');
        infowindow.open(map, this);
      });
    }
  });
}

Most helpful comment

+1

All 5 comments

+1

@istarkov ?

?

@istarkov can google-map-react show building name/location name on map? I read the document and cannot find any information about this. If you close this issue, please give some conclusion, thanks.

@jie-meng I think the reason why my friend istarkov closed the issue, is because:

This library places React Components in the map instead of markers, right? Therefore, if you want to show a building name / location on the map, you can just do it with the component you're using.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SachaG picture SachaG  路  4Comments

kirylkliushkin picture kirylkliushkin  路  4Comments

figalex picture figalex  路  4Comments

matanhalevy picture matanhalevy  路  4Comments

SantosOMartinez picture SantosOMartinez  路  4Comments