[英]Google Maps Api Get Details Request Not Working
I am having trouble to make a google map, whenever the user clicks on the marker, I would like them to see a info window with images. 我在制作Google地图时遇到了麻烦,每当用户单击标记时,我希望他们看到带有图像的信息窗口。 I have been able to do everything, but for the images, I tried a Get details request, and for some reason it didn't work. 我已经能够执行所有操作,但是对于图像,我尝试了“获取详细信息”请求,由于某种原因,该请求不起作用。
function createMapMarker(placeData) {
count++;
var lat = placeData.geometry.location.lat();
var lon = placeData.geometry.location.lng();
var name = placeData.formatted_address;
var bounds = window.mapBounds;
position = placeData.geometry.location;
var marker = new google.maps.Marker({
map: map,
position: position,
title: name
});
bounds.extend(new google.maps.LatLng(lat, lon));
map.fitBounds(bounds);
map.setCenter(bounds.getCenter());
getDetails();
function getDetails() {
var service = new google.maps.places.PlacesService(map);
var request = {
placeId: placeData.place_id
}
service.getDetails(request, getCallBack);
}
function getCallBack(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
infowindow(results[0]);
}
}
function infowindow(place) {
var infowindow = new google.maps.InfoWindow();
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent("<img src='"+place.photos[0].getUrl+"'><br>"+placeData.name+"<br>"+placeData.formatted_address+"<br>Rating:"+placeData.rating+" stars<br>");
infowindow.open(map, this);
});
}
}
To get images to show on the 'Window' once clicked on the marker you could do: 要在单击标记后将图像显示在“窗口”上,可以执行以下操作:
infowindow.imageView.image = UIImage(named: "image.jpg").
Hope this helps :) 希望这可以帮助 :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.