Jump to content
Fórum Script Brasil
  • 0

WebBrowser + javascript


PJRH

Question

Ola todos,

Tenho um código em VB 2008 com utilização do webBrowser. Antes de chamá-lo gravo um htm contendo linhas de uma chamada em JavaScript, o que roda perfeitamente se acessar fora do VB, mas quando rodo no VB da o seguinte erro: Constante de sequencia não finalizada. Já entendi o erro, mas não localizo, pois funciona fora do VB. Segue o código:

Dim w As StreamWriter = File.CreateText("mapas.htm")


                        w.WriteLine("<html>")
                        w.WriteLine("<head>")
                        w.WriteLine("<title></title>")
                        w.WriteLine("<style type='text/css'>")
                        w.WriteLine("html, body, #map_canvas {")
                        w.WriteLine("   margin: 0;")
                        w.WriteLine("   padding: 0;")
                        w.WriteLine("   width: 250;")
                        w.WriteLine("   height: 200;")
                        w.WriteLine("   }")
                        w.WriteLine("</style>")

                        w.WriteLine("&lt;script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?sensor=false'></script>")
                        w.WriteLine("&lt;script type='text/javascript'>")
                        w.WriteLine("var map;")
                        w.WriteLine("function initialize() {")

                        w.WriteLine("var myOptions = {")
                        w.WriteLine("   zoom: " + Str(Trim(Me.numMapa.Value)) + ",")
                        w.WriteLine("   disableDefaultUI: true,")
                        w.WriteLine("   center: new google.maps.LatLng(" + vAx + "," + vBx + "),")
                        w.WriteLine("   mapTypeId: google.maps.MapTypeId." + Me.cboTipoMapa.AutoCompleteCustomSource.Item(Me.cboTipoMapa.SelectedIndex))
                        w.WriteLine("};")

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


                        w.WriteLine("var imageA = new google.maps.MarkerImage('Images/airplaneNew.png', new google.maps.Size(68, 68));")
                        w.WriteLine("var myLatlngA = new google.maps.LatLng(" + vAx + "," + vBx + ");")


                        w.WriteLine("var markerA = new google.maps.Marker({") 'aqui está o erro que só aparece na chamada do webBrowser
                        w.WriteLine("   position: myLatlngA,")
                        w.WriteLine("   map: map,")
                        w.WriteLine("   icon: imageA")
                        w.WriteLine("});")                                                          'fim do erro - se colocar rem nessas linhas roda, mas...

'
                        w.WriteLine("}")

                        w.WriteLine("google.maps.event.addDomListener(window, 'load', initialize);")
                        w.WriteLine("</script>")
                        w.WriteLine("</head>")
                        w.WriteLine("<body>")
                        w.WriteLine("<div id='map_canvas'></div>")
                        w.WriteLine("</body>")
                        w.WriteLine("</html>")

                        w.Close()

                        Me.WebBrowser1.Navigate(CurDir() + "\mapas.htm") ' mas, so aparece quando chega aqui

Abraços

Edited by kuroi
Adicionar tag CODE
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...