【发布时间】:2016-01-11 06:41:04
【问题描述】:
我需要在 InfoWindow 中显示 match.offer.text。 每个标记都有不同的 match.offer.text。
这是我的代码:
var markerImageURL, lat, lng;
if (myoffer) {
markerImageURL = 'assets/img/markers/marker_my.png';
lat = match.lat;
lng = match.lng;
} else {
markerImageURL = 'assets/img/markers/marker_' + match.strength + '.png';
lat = match.offer.lat;
lng = match.offer.lng;
}
var marker = new google.maps.Marker({
position: new google.maps.LatLng(lat, lng),
map: window.googleMap,
icon: {
size: new google.maps.Size(54,56),
url: markerImageURL
},
draggable: false,
visible: true
});
var infowindow = new google.maps.InfoWindow({
content: match.offer.text,
maxWidth: 300
});
window.googleMapMarkers.push(marker);
if(!myoffer) {
window.MVC.Events.GoogleMap.prototype.showInfoWindow(marker, infowindow, match);
}
点击标记后触发的事件:
marker.addListener('click', function() {
infowindow.open(window.googleMap, marker);
}
请帮帮我。
【问题讨论】:
-
您的开发者工具控制台中是否出现任何错误?你的代码目前在做什么?
-
请提供一个Minimal, Complete, Tested and Readable example 来证明您的问题。
-
Jaromanda X:当我给内容一个字符串时,它会在任何地方显示相同的文本
content: "text",当内容是控制台中的“match.offer.text”时,我有:Potentially unhandled rejection [1] window.MVC.Events.GoogleMap.prototype.addGoogleMapMarker@file:///D:/Zlecenia/...
标签: javascript google-maps infowindow