I need to show building name/location name on map like this
Are there any ways to support this feature?
Thank you.
// 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);
});
}
});
}
+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.
Most helpful comment
+1