Google 地图 v3 - 将 url 附加到 iframe
Google map v3 - attaching a url to a iframe
我正在尝试将 URL 附加到 iframe,当单击事件侦听器时不确定这是否是正确的方法。
var locations = [
['Station 1', -32.77255333509087, 151.64851427078247, 1, www.url.com],
['Station 2', -32.75009, 151.73467000000405, 2, www.url.com],
['Station 3', -32.79854, 151.64355, 3, www.url.com],
];
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2], url: place[4]),
map: map, icon: icon_station, animation: google.maps.Animation.BOUNCE
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
$("#station_frame").attr("src", "URL Goes here?");
}
})(marker, i));
}
将 "URL goes here?"
替换为:
locations[i][4]
...它应该可以工作。
注意:
您的这部分代码是错误的并强制出现语法错误:
new google.maps.LatLng(locations[i][1], locations[i][2], url: place[4])
必须是:
new google.maps.LatLng(locations[i][1], locations[i][2])
我正在尝试将 URL 附加到 iframe,当单击事件侦听器时不确定这是否是正确的方法。
var locations = [
['Station 1', -32.77255333509087, 151.64851427078247, 1, www.url.com],
['Station 2', -32.75009, 151.73467000000405, 2, www.url.com],
['Station 3', -32.79854, 151.64355, 3, www.url.com],
];
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2], url: place[4]),
map: map, icon: icon_station, animation: google.maps.Animation.BOUNCE
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
$("#station_frame").attr("src", "URL Goes here?");
}
})(marker, i));
}
将 "URL goes here?"
替换为:
locations[i][4]
...它应该可以工作。
注意: 您的这部分代码是错误的并强制出现语法错误:
new google.maps.LatLng(locations[i][1], locations[i][2], url: place[4])
必须是:
new google.maps.LatLng(locations[i][1], locations[i][2])