【发布时间】:2013-11-20 15:17:03
【问题描述】:
我正在尝试通过嵌入在我的 VB.net 应用程序中的 Web 浏览器打开 Google Map API。我可以通过从本地桌面加载 HTML 文件来做到这一点:
WebBrowser1.Navigate("file:///" & "C:\Users\username\Desktop\google-maps.html")
但现在我想直接在我的 VB 应用程序中手动添加我的 HTML 文件的内容:
sHTML = "<!DOCTYPE html><html><head>" _
& "<meta name='viewport' content='initial-scale=1.0, user-scalable=no'/>" _
& "<style type='text/css'>" _
& "html { height: 100% }" _
& "body { height: 100%; margin: 0; padding: 0 }" _
& "#map-canvas { height: 100% }" _
& "</style>" _
& "<script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?key= <KEY>&sensor=false&libraries=weather'></script>" _
& "<script type='text/javascript'>" _
& "function initialize() {" _
& "var mapOptions = {" _
& "center: new google.maps.LatLng(46.073231,4.21875)," _
& "zoom: 2" _
& "};" _
& "var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);" _
& "};" _
& "google.maps.event.addDomListener(window, 'load', initialize);" _
& "</script></head><body>" _
& "<div id='map-canvas'/>" _
& "</body></html>"
WebBrowser1.Document.Write(sHTML)
但是当我运行此代码时,我必须看到以下错误消息:“google is undefined”。有什么想法吗?
谢谢。
【问题讨论】:
-
试试我的回答应该会有帮助