我无法制作谷歌地图,每当用户点击标记时,我希望他们看到带有图像的信息窗口。我已经能够做所有事情,但对于图像,我尝试了获取详细信息请求, 由于某种原因它没有用。
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);
});
}
}
答案 0 :(得分:-1)
要在&#39; Window&#39;上显示图像。点击你可以做的标记:
infowindow.imageView.image = UIImage(named: "image.jpg").
希望这会有所帮助:)