gpt4 book ai didi

c# - 谷歌地图 API 和 C#

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

我的 map 有问题。 map 在大约 5 个月前工作正常。现在,当我用我的坐标加载 map 时, map 正在加载,但是当我开始浏览 map 、缩放等时,我得到白屏,就像与 map 没有连接一样。我需要再次加载 map ,但同样的问题又发生了.大约 5 个月前,我在使用这个脚本,一切正常。浏览、缩放、更改 map 类型,一切都没有任何问题。我已经根据谷歌网站创建了 html 代码并将其放入新的资源文件中:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<title>Google Maps JavaScript API v3 Example: Map Simple</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">



function load(latitude,longitude,zoomik) {
var myLatlng = new google.maps.LatLng(latitude,longitude);
var myOptions = {
zoom: zoomik,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}


var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title:"Here!"});

}

</script>
</head>
<body onload="load()">
<div id="map_canvas"></div>
</body>
</html>

我的按钮代码是:

  private void TestButton_Click(object sender, EventArgs e)
{
webBrowser1.Document.InvokeScript("load", new object[] { -34.397, 150.644, 8 });
}

屏幕:正确加载 map : enter image description here

使用平移工具或缩放工具后:- 空白屏幕。 enter image description here

我正在使用来自 winforms 的 Visual C# Express 和 WebBrowser 控件。

HTML 代码在 Firefox 中正常工作(使用 Aptana Studio)(缩放和平移工作正常)

还有什么来自 google api 示例的代码也无法正常工作:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<title>Google Maps JavaScript API v3 Example: Map Simple</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize() {
var myLatlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas"></div>
</body>
</html>

最佳答案

这是我自己想出来的。

错误的是:

<div id="map_canvas"></div>

将其更改为:

<div id="map_canvas" style="width:500px; height:400px"></div>

map 正常工作。

关于c# - 谷歌地图 API 和 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6315373/

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