I'm having trouble adding some of Google Places API data types to an info window that will display data when a user clicks on a marker on the map. I have included the following data types place.name
, place.rating
, place.vacinity
and these will successfully display the name, rating, and address of the establishment in the info window. However when I try to add place.url
to return the "URL of the official Google page for this place", it returns undefined
. These establishments have the URL if I search them via Google so I know that there are URLs however it just cannot access them for some reason?
This is the Javascript code snippet that creates the marker and adds the info window to the listener that will be called when clicked.
function createMarker(place) {
infowindow = new google.maps.InfoWindow();
var placeLoc = place.geometry.location;
var reportmarker = new google.maps.Marker({
map: map,
position: place.geometry.location
});
markers.push(reportmarker);
google.maps.event.addListener(reportmarker, 'click', function() {
infowindow.setContent("<p>" + place.name + "<br />" + place.rating + "<br />" + place.vicinity + "<br />" + place.url+ "<br />" +"</p>");
infowindow.open(map, this);
});
}