I newly want to use the googlemap api to display some markers on a map in a simple C# windows form with visual studio.
I use a "web browser" component to display a generated html file with the basic html code from google plus customized coordinate.
const string htmlPath = "D:/map.html";
StreamWriter sw = new StreamWriter(htmlPath, false, System.Text.Encoding.GetEncoding(437));
string centerLongitude = centerLongitudeTextBox.Text;
string centerLatitude = centerLatitudeTextBox.Text;
sw.WriteLine("<!DOCTYPE html>");
sw.WriteLine("<html>");
sw.WriteLine("<head>");
sw.WriteLine("<meta charset=\"utf-8\">");
sw.WriteLine("<style>");
sw.WriteLine("html, body, #map{");
sw.WriteLine("margin :0;");
sw.WriteLine("padding: 0;");
sw.WriteLine("height: 100%");
sw.WriteLine("}");
sw.WriteLine("</style>");
//sw.WriteLine("<link rel=\"stylesheet\" href=\"/maps/documentation/javascript/demos/demos.css\">");
sw.WriteLine("</head>");
sw.WriteLine("<body>");
sw.WriteLine("<div id=\"map\"></div>");
sw.WriteLine("<script>");
sw.WriteLine("function initMap() {");
sw.WriteLine("// Create a map object and specify the DOM element for display.");
sw.WriteLine("var map = new google.maps.Map(document.getElementById('map'), {");
sw.WriteLine("center: { lat: "+ centerLatitude +", lng: "+ centerLongitude +"},");
sw.WriteLine("scrollwheel: false,");
sw.WriteLine("zoom: 8");
sw.WriteLine("});");
sw.WriteLine("}");
sw.WriteLine("</script>");
sw.WriteLine("<script src=\"https://maps.googleapis.com/maps/api/js?key=MYKEY of course&callback=initMap\"");
sw.WriteLine("async defer></script>");
sw.WriteLine("</body>");
sw.WriteLine("</html>");
sw.Close();
webBrowser1.Navigate("file:///" + htmlPath);
This code is working good, but my application text me that java script generate errors.
Can you give me some help, i don't understand why there is this error and finding topics or code exemple is hard.
Thanks you for reading me.