【发布时间】:2015-05-19 15:51:56
【问题描述】:
我正在使用 Kendo ASP.NET 处理用户信息弹出窗口。弹出窗口还包含使用@Html.Kendo().TabStrip() 创建的选项卡。
到目前为止,显示和输入数据工作正常。但是,我无法在弹出编辑器中添加地图。
这是示例弹出窗口。有街道名称、街道号码等。虽然谷歌地图还没有与数据交互,但我希望它能正确显示。
Location.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 中添加按钮并在单击按钮时初始化地图。
如果我在这里遗漏了什么,请指导我。
【问题讨论】:
-
你的
<div>在TabStrip的内容中怎么没有结束标签? -
ataravati,有结束标签。我只是在复制代码时错过了它。
标签: javascript google-maps google-maps-api-3 kendo-asp.net-mvc kendo-ui-mvc