我正在使用 Kendo ASP.NET 处理用户信息弹出窗口。弹出窗口还具有使用创建的选项卡@Html.Kendo().TabStrip()
。
到目前为止,显示和输入数据工作正常。但是,我无法将地图添加到弹出编辑器中。
这是示例弹出窗口。有街道名称、街道号码等。虽然谷歌地图还没有与数据交互,但我希望它正确显示。
位置.cshtml:
@(Html.Kendo().TabStrip()
.Name("tabstripLocationPopup")
.Items(tabstrip =>
{
tabstrip.Add().Text("Location")
.Selected(true)
.LoadContentFrom("", "")
.Content(@<text>
<div id="GeoLocation" class="tab" style="overflow: auto; height: 90%;">
<fieldset>
<legend accesskey="I">Identification</legend>
<table border="0" style="width: 95%; margin: 0 auto; border-collapse: collapse; border: 0px solid black;">
<tr>
<td class="label">
@Html.LabelFor(model => model.Lat, "Latitude")
</td>
<td class="editor">
@Html.Kendo().MaskedTextBoxFor(model => model.Lat).Name("Lat")
</td>
<td class="label">
@Html.LabelFor(model => model.Long, "Longitude")
</td>
<td class="editor">
@Html.Kendo().MaskedTextBoxFor(model => model.Long).Name("Long")
</td>
<tr>
</table>
</fieldset>
</div>
</text>);
})
)
我在 index.cshtml 中添加了脚本:
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?key=MyAPICode&sensor=false">
</script>
<script type="text/javascript">
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
}
</script>
如果我将此代码添加到 index.cshtml 文件中,则地图会正确显示。
<body onload="initialize()">
<div id="map_canvas" style="width:500px; height:200px"></div>
</body>
但是,我希望它显示在弹出窗口(Location.cshtml)中。
我让它显示的唯一方法是在 Javascript 中添加按钮并在单击按钮时初始化地图。
如果我在这里遗漏了什么,请指导我。