Reputation: 43
I'm trying to open the Google Map API through a Web browser embeded in my VB.net application. I can do it by loading an HTML file from the local desktop using:
WebBrowser1.Navigate("file:///" & "C:\Users\username\Desktop\google-maps.html")
But now I would like to manualy add the content of my HTML file directly in my VB application:
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)
But when I run this code I have to following error message : "google is undefined". Any ideas ?
Thank you.
Upvotes: 0
Views: 1031
Reputation: 1182
you have to do like this
WebBrowser1.Documenttext = shtml
if you want to load webbrowser from html
file
use like this
Webbrowser1.DocumentText = System.IO.File.ReadAllText("c:\myhtml.html")
Upvotes: 1