我正在开发一个 ASP.NET 项目,并且在其中使用 Google Maps。我在页面加载时加载地图。然后通过单击一个按钮,我想添加一些标记。我正在使用以下代码。
function LoadSecurity(locationList, message) {
if (document.getElementById("map_canvas") != null &&
document.getElementById("map_canvas") != "null") {
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
for (var i = 0; i < locationList.length; i++) {
if ((i == 0) || (i == locationList.length - 1)) {
var args = locationList[i].split(",");
var location = new google.maps.LatLng(args[0], args[1])
var marker = new google.maps.Marker({
position: location,
map: map
});
marker.setTitle(message[i]);
}
}
}
}
我使用以下代码在按钮上调用该函数。
<asp:Button ID="Button1" runat="server"
OnClientClick="javascript: LoadSecurity('57.700034,11.930706','test')"
Text="Button" />
但不工作。请问有什么帮助吗?