-1
Google Map with KMLを表示するC#WebBrowserを含むWindowsフォームを作成したいとします。問題は、コードを実行した後、Webブラウザに何も表示されないということです。私は私のプロジェクトにこれが必要です。ここでC#WebBrowserのKMLを使用したGoogleマップ
は私のコードです:
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser123.DocumentText =
"<!DOCTYPE html>" +
"<html>" +
"<head>" +
"<meta name=\"viewport\" content=\"initial-scale=1.0\">" +
"<meta charset=\"utf-8\">" +
"<title>KML Layers</title>" +
"<style>" +
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
"#map {" +
" height: 100%;" +
"}" +
/* Optional: Makes the sample page fill the window. */
"html, body {" +
"height: 100%;" +
"margin: 0;" +
"padding: 0;" +
" }" +
"</style>" +
"</head>" +
"<body>" +
" <div id=\"map\"></div>" +
"<script>" +
"function initMap() {" +
" var map = new google.maps.Map(document.getElementById('map'), {" +
" zoom: 11," +
"center: {lat: 41.876, lng: -87.624}" +
" });" +
" var ctaLayer = new google.maps.KmlLayer({" +
" url: 'http://googlemaps.github.io/js-v2-samples/ggeoxml/cta.kml'," +
" map: map" +
" });" +
" }" +
"</script>" +
"<script async defer" +
"src=\"https://maps.googleapis.com/maps/api/js?key=AIzaSyAsLmzxet8OI2SHDZ78c3MJdTP1ODoFjZg&callback=initMap\">" +
"</script>" +
"</body>" +
"</html>";
// webBrowser.DocumentText =
//"<html><body>Please enter your name:<br/>" +
//"<input type='text' name='userName'/><br/>" +
//"<a href='http://www.microsoft.com'>continue</a>" +
//"</body></html>";
}
}
}