【发布时间】:2018-03-01 16:46:40
【问题描述】:
我编写了一个脚本来显示多个地图标记并通过邮政编码进行搜索,或者地址也显示多个标记与用户给定位置之间的距离但是..我想显示带有一些内容的 infoWindow写给每个标记...有人可以帮助我吗?
脚本是这样的:
var features = [
{
position: new google.maps.LatLng(38.089374, 23.809245),
type: 'info'
}, {
position: new google.maps.LatLng(37.865212, 23.744748),
type: 'info'
}, {
position: new google.maps.LatLng(37.997172, 23.693429),
type: 'info'
}, {
position: new google.maps.LatLng(37.934769, 23.879542),
type: 'info'
}, {
position: new google.maps.LatLng(38.003720, 23.886767),
type: 'info'
}, {
position: new google.maps.LatLng(38.027083, 23.850951),
type: 'info'
}, {
position: new google.maps.LatLng(37.944077, 23.661457),
type: 'info'
}, {
position: new google.maps.LatLng(38.017348, 23.796585),
type: 'info'
}, {
position: new google.maps.LatLng(37.955754, 23.677229),
type: 'info'
}, {
position: new google.maps.LatLng(37.971261, 23.756350),
type: 'info'
}, {
position: new google.maps.LatLng(37.990022, 23.720621),
type: 'info'
}, {
position: new google.maps.LatLng(38.050031, 23.752440),
type: 'info'
}, {
position: new google.maps.LatLng(38.464754,23.615317),
type: 'info'
}, {
position: new google.maps.LatLng(37.943692, 23.748214),
type: 'info'
}, {
position: new google.maps.LatLng(39.544696, 21.775843),
type: 'info'
}, {
position: new google.maps.LatLng(40.668344, 22.889161),
type: 'info'
}, {
position: new google.maps.LatLng(40.662039, 22.911951),
type: 'info'
}, {
position: new google.maps.LatLng(40.573629, 23.025070),
type: 'info'
}, {
position: new google.maps.LatLng(40.303271, 21.804128),
type: 'info'
}
];
// edw oi kaloi oi markers.
features.forEach(function(feature) {
var marker = new google.maps.Marker({
position: feature.position,
icon: icons[feature.type].icon,
map: map
});
});
【问题讨论】:
-
发布的代码中没有InfoWindows。
-
是的,因为无论我如何尝试插入 InfoWindows,它们都无法正常工作。如您所见,var 功能是我的标记,即使我为 infowindow 输入任何代码也不会显示,或者当我单击时我可以看到窗口但它是空的......(如果我没有制作,请原谅我很明显,我对此很陌生)
-
当您尝试插入信息窗口时,您能否展示您的代码的外观?然后我们可以告诉你你做错了什么。
标签: javascript api google-maps google-maps-api-3 google-maps-markers