gpt4 book ai didi

c# - 将加载指示器添加到谷歌地图 infoWindow

转载 作者:太空宇宙 更新时间:2023-11-03 16:30:28 26 4
gpt4 key购买 nike

目前,当用户单击我们 map 屏幕上的位置标记时,将调用页面方法以从服务器检索附加信息。当 page 方法成功时,结果用于定义显示在 map 上的 infoWindow 的内容。在 page 方法很慢的情况下,我们希望 infoWindow 立即显示,但带有加载指示器。 page方法成功后,会更新infowWindow的内容。

到目前为止,我天真的方法是先创建带有加载指示器的 infoWindow,并通过调用 open(map) 显示这个初始 infoWindow,然后在 page 方法成功后更新该 infoWindow 的内容。然而,这种方法不起作用,因为直到页面方法完成后 map Canvas 才会更新(因此永远不会显示 infoWindow 的初始版本)。

----- 页面代码-----

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?v=3.8&client=MY_CLIENT&sensor=false"></script>

<script type="text/javascript">

function initialize_map() {
map = new google.maps.Map(...);
// set remaining map properties...
}

window.onload = function () {
initialize_map();
}

function DrawPoint(loc) {
var marker = GetPointMarker(loc);
// set remaining point marker properties...
marker.setMap(map);

var showPointInfo = function (evt) {
var infoWindow = infowindowList[loc];
if (infoWindow == undefined)
{
GetPointInfoStart(loc);
GetPointInfo(loc);
}
};

google.maps.event.addListener(marker, 'click', showPointInfo);
}

function GetPointInfoStart(loc)
{
var infoWindow = new google.maps.InfoWindow();
var content = // initial content with loading indicator
infoWindow.setContent(content);
// set remaining infoWindow properties...
infoWindow.open(map);
}

function GetPointInfo(loc)
{
// call page method to retrieve data for infoWindow
PageMethods.GetMapPointInfo(..., OnGetPointInfoSuccess, OnFailure);
}

function OnGetPointInfoSuccess(result) {
eval(result);
var infoWindow = infowindowList[loc];
var content = // final content with retrieved data
infoWindow.setContent(content);
}

</script>

----- 代码隐藏-----

protected override void OnInit(EventArgs e)
{
ScriptManager.GetCurrent(this).EnablePageMethods = true;
...
base.OnInit(e);
}

[WebMethod]
public static string GetMapPointInfo(...)
{
// retrieve point information from server...
return jsonString;
}

最佳答案

我发现初始内容的定义方式存在错误。内容现在已正确定义,方法(如上所述)现在起作用了。

关于c# - 将加载指示器添加到谷歌地图 infoWindow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10986887/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com