【发布时间】:2013-05-09 19:51:10
【问题描述】:
所以我设法让标记和信息窗口使用 razor 和 google maps api 进行以下操作:
@{
IEnumerable<UFA.Location.Core.Location> Location = UFALocation___Front.Helpers.QueryHelper.QueryHelper.getAllLocations();
foreach(var loc in Location){
<text>
var contentString_@loc.id = "@loc.name";
mapMarker_@loc.id = new google.maps.Marker({
position: new google.maps.LatLng(@loc.latitude, @loc.longitude),
map: map,
title: "Hello World!"
});
var infoWindow = new google.maps.InfoWindow({
content: contentString_@loc.id
});
google.maps.event.addListener(mapMarker_@loc.id, 'click', function() {
infoWindow.open(map, mapMarker_@loc.id);
});
</text>
}
}
更新
所以它显示为每个位置的信息框,如我所愿,但其中的内容只是最后一个位置的名称,与位置无关。本质上,信息框与任何一个特定位置无关,即使我为每个 ID 都制作了它们,如果这有意义的话。
【问题讨论】:
标签: asp.net-mvc-4 razor google-maps-api-3