[英]Map doesn't load second time i click
I want to show my open street map on a Kendo UI window. 我想在Kendo UI窗口上显示打开的街道地图。 At First time on click the map shows, but after that it doesn't load.
首次点击时,地图会显示,但此后不会加载。 Even if I use google map the same result.
即使我使用谷歌地图相同的结果。 After searching on google, I have found that we can not initialize map more than one time.
在Google上搜索后,我发现我们不能多次初始化地图。 I have tried in different ways, but it doesn't work.
我已经尝试了不同的方法,但是没有用。 May be my approach was not good.
可能是我的方法不好。 Here 'is my code
这是我的代码
var data=' ';
function createMap() {
data = $("#map").kendoMap({
center: [23.7099, 90.4071],
zoom: 15,
layers: [
{
type: "tile",
urlTemplate: "http://#= subdomain #.tile2.opencyclemap.org/transport/#= zoom #/#= x #/#= y #.png",
subdomains: ["a", "b", "c"],
attribution: "© <a href='http://osm.org/copyright'>OpenStreetMap</a>."
}
]
});
}
function showMap(e) {
e.preventDefault();
var wnd = $("#Map").data("kendoWindow");
createMap();
wnd.content(data);
wnd.center().open();
}
@(Html.Kendo().Window().Name("Map")
.Title("<span class='glyphicon glyphicon-map-marker'></span> Map of the road")
.Visible(false)
.Modal(true)
.Draggable(true)
.Width(635)
)
ShowMap fire on user click 用户点击即可触发ShowMap
You have to redraw the map. 您必须重新绘制地图。 You can do this using the following code:
您可以使用以下代码执行此操作:
google.maps.event.trigger(map, 'resize');
This will make the map refresh, fixing your issue. 这将使地图刷新,从而解决了您的问题。
请在函数末尾尝试
$("#map").data("kendoMap").resize();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.