Solved

javascript (?) could not complete the operation  due to error 80020101

Posted on 2016-11-20
64
47 Views
Last Modified: 2016-11-26
I am trying to connect to BING and with strong help from EE I was able to develop and test the link and it works. Now I had to bring the code to my main DB and I getting the above error.

My source is:

Private Sub Form_Load()

    Dim dbl_latGPS, dbl_lgtGPS As Double
    Dim strLetraPushPin, _
        strTitulo, _
        strSubTitulo, _
        strLatGPS, _
        strLgtGPS As String


    ' não há erros (para já) e ir buscar a página com o template
    ' carregar os pontos todos para afixar
        
    Call logMe("Form_Load", "viewNewGPS")
    
    Me.ctlWebBrowser.Object.Silent = True
    Set m_WebBrowser = ctlWebBrowser.Object
    m_WebBrowser.Navigate "c:\temp\map.html"
    
    dbl_latGPS = Forms![_commonVariables]![LatGPS]
    dbl_lgtGPS = Forms![_commonVariables]![LgtGPS]
    strLatGPS = Format(dbl_latGPS, "000.0000000")
    strLgtGPS = Format(dbl_lgtGPS, "000.0000000")

    strLetraPushPin = Forms![_commonVariables]![letraPushPin]
    strTitulo = "[" & Forms![_commonVariables]![codigoPonto] & "].[" & _
                Forms![_commonVariables]![MarcaPonto] & "]"
    strSubTitulo = "[" & Forms![_commonVariables]![TipoPonto]

    Debug.Print "lat:" & strLatGPS
    Debug.Print "lon:" & strLgtGPS
    Debug.Print "letra:" & strLetraPushPin
    Debug.Print "tit:" & strTitulo
    Debug.Print "subtit:" & strSubTitulo
    'mostrar o pushpin
    
    
    InvokeJavaScript "addPushpin(strLatGPS, strLgtGPS, strLetraPushPin, strTitulo, strSubTitulo');"


    
End Sub

Open in new window


the values are:

(I use debug.print)

lat:011.8161111
lon:-015.7213889
letra:X
tit:[PDA.36G017].[Mua]
subtit:[Fonte

and the  error occurs on

   InvokeJavaScript "addPushpin(strLatGPS, strLgtGPS, strLetraPushPin, strTitulo, strSubTitulo');"

Open in new window



my html page is attached.


can anyone help?
0
Comment
Question by:jirdeaid
  • 32
  • 32
64 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 41895082
replace :
InvokeJavaScript "addPushpin(strLatGPS, strLgtGPS, strLetraPushPin, strTitulo, strSubTitulo');"

Open in new window

by :
InvokeJavaScript "addPushpin(strLatGPS, strLgtGPS, strLetraPushPin, strTitulo, strSubTitulo);"

Open in new window


there's a simple quote a the end we don't want
0
 

Author Comment

by:jirdeaid
ID: 41895098
you're right - that ['] should never be there.. but behaviour is still the same - same error. I must be wrongdoing elsewhere....
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41895099
test with this and confirm the error leave
InvokeJavaScript "alert('ok');"

Open in new window

0
 

Author Comment

by:jirdeaid
ID: 41895102
Debug.Print "lat:" & strLatGPS
    Debug.Print "lon:" & strLgtGPS
    my code is:

Debug.Print "letra:" & strLetraPushPin
    Debug.Print "tit:" & strTitulo
    Debug.Print "subtit:" & strSubTitulo
    'mostrar o pushpin
   
   
    'InvokeJavaScript "addPushpin(strLatGPS, strLgtGPS, strLetraPushPin, strTitulo, strSubTitulo);"
    InvokeJavaScript "alert('ok');"


and got:


Screen-Shot-2016-11-20-at-21.08.03.png
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41895106
you need to replace the string by their values :
InvokeJavaScript "addPushpin(" + strLatGPS + ", " + strLgtGPS + "," + strLetraPushPin + "," + strTitulo + "," + strSubTitulo + ");"

Open in new window

0
 

Author Comment

by:jirdeaid
ID: 41895136
Ok.

your code yields exactly the same error (I copied like that to my source code).

then I replaced my code


I have replace my code again:

and got (same error) and:

lat:011.8161111
lon:-015.7213889
letra:'X'
tit:'[PDA.36G017].[Mua]'
subtit:'[Fonte]'

so all parameters look good.

but the error persists...


any hint?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41895143
We need to add quotes around the string, I'm not front of my desk I think you follow me :
Use '" + the_string + "',
Instead " + the_string + ",
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41895214
try this :
InvokeJavaScript "try { addPushpin(" + strLatGPS + ", " + strLgtGPS + ",'" + strLetraPushPin + "','" + strTitulo + "','" + strSubTitulo + "''); } catch(err) { alert(err); }"

Open in new window

0
 

Author Comment

by:jirdeaid
ID: 41895569
nope... always the same error...


could it be from the lenght of the parameters' content?

my code is:

Private Sub Form_Load()

    Dim dbl_latGPS, dbl_lgtGPS As Double
    Dim strLetraPushPin, _
        strTitulo, _
        strSubTitulo, _
        strLatGPS, _
        strLgtGPS As String


    ' não há erros (para já) e ir buscar a página com o template
    ' carregar os pontos todos para afixar
        
    Call logMe("Form_Load", "viewNewGPS")
    
    Me.ctlWebBrowser.Object.Silent = True
    Set m_WebBrowser = ctlWebBrowser.Object
    m_WebBrowser.Navigate "c:\temp\map.html"
    
    dbl_latGPS = Forms![_commonVariables]![LatGPS]
    dbl_lgtGPS = Forms![_commonVariables]![LgtGPS]
    strLatGPS = Format(dbl_latGPS, "###.0000000")
    strLgtGPS = Format(dbl_lgtGPS, "###.0000000")

    strLetraPushPin = Forms![_commonVariables]![letraPushPin]
    strTitulo = Forms![_commonVariables]![codigoPonto]
    strSubTitulo = Forms![_commonVariables]![TipoPonto]

    Debug.Print "lat:" & strLatGPS
    Debug.Print "lon:" & strLgtGPS
    Debug.Print "letra:" & strLetraPushPin
    Debug.Print "tit:" & strTitulo
    Debug.Print "subtit:" & strSubTitulo
    'mostrar o pushpin
    Debug.Print strLatGPS & " / " & strLgtGPS & "/" & strLetraPushPin & "/" & strTitulo & "/" & strSubTitulo
    
    
    InvokeJavaScript "try { addPushpin(" + strLatGPS + ", " + strLgtGPS + ",'" + strLetraPushPin + "','" + strTitulo + "','" + strSubTitulo + "''); } catch(err) { alert(err); }"
    'InvokeJavaScript "addPushpin(strLatGPS, strLgtGPS, strLetraPushPin, strTitulo, strSubTitulo);"
    'InvokeJavaScript "alert('ok');"
    'InvokeJavaScript "addPushpin(" + strLatGPS + ", " + strLgtGPS + "," + strLetraPushPin + "," + strTitulo + "," + strSubTitulo + ");"

    
End Sub

Open in new window


and the string content of the parameters is:

lat:11.8161111
lon:-15.7213889
letra:X
tit:PDA.36G017
subtit:Fonte


reconfirmd: 11.8161111 / -15.7213889/X/PDA.36G017/Fonte
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41895577
ok could you check this for me :
InvokeJavaScript "alert(typeof addPushpin);"
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41895584
if you don't get undefined, this one too :
InvokeJavaScript "alert(String(addPushpin));"

thanks
0
 

Author Comment

by:jirdeaid
ID: 41895727
'got UNDEFINED....
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41895740
Do you've the map on the page? at least ? :D
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41895753
assuming you've something similar to that in your page :
<body onload="GetMap();">
      <div id='mapDiv' style="position:relative; width:400px; height:400px;"></div>       
   </body>

Open in new window


and this in the header (please not I added the missing addPushpin function)

      <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>

      <script type="text/javascript">

      var map = null;

      function GetMap()
      {  

         map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), {credentials: "Bing Maps Key"});

      }

      function SetLocation()
      {
         // Parse the input string
         var latLongArray = (document.getElementById("txtlatlong").value).split(",");

         // Retrieve the latitude and longitude values- normalize the longitude value
         var latVal = parseInt(latLongArray[0]);
         var longVal = Microsoft.Maps.Location.normalizeLongitude(parseInt(latLongArray[1]));

         // Set the map center
         map.setView({center:new Microsoft.Maps.Location(latVal, longVal)});

      }

      function addPushpin(strLatGPS, strLgtGPS, strLetraPushPin, strTitulo, strSubTitulo) {
         var center = new Microsoft.Maps.Location(strLatGPS*1, strLgtGPS*1);
         var pin = new Microsoft.Maps.Pushpin(center, {text: strLetraPushPin}); 
         map.entities.push(pin);
         map.setView({center:center});         
      }


      </script>

Open in new window

0
 

Author Comment

by:jirdeaid
ID: 41896030
Hi. I have sent the page before... let me resend it to  you...
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41896044
ok, no worry, just add this bit of JS at the end of you current Javascript block :

      function addPushpin(strLatGPS, strLgtGPS, strLetraPushPin, strTitulo, strSubTitulo) {
         var center = new Microsoft.Maps.Location(strLatGPS*1, strLgtGPS*1);
         var pin = new Microsoft.Maps.Pushpin(center, {text: strLetraPushPin}); 
         map.entities.push(pin);
         map.setView({center:center});         
      }

Open in new window

0
 

Author Comment

by:jirdeaid
ID: 41896062
Ok.

moment
0
 

Author Comment

by:jirdeaid
ID: 41896106
Ok. here it is.

I have changed the map.html file to your recent content (and included my bing key) as it looks much better and clean than what I had before.
then started the code.

now the behaviour is different.
1. it starts OK
2. then I get "access is denied":

s1
3. the I get a "request permission..."


s2


... and a blank screen...


s3

my code is:


Private Sub Form_Load()

    Dim dbl_latGPS, dbl_lgtGPS As Double
    Dim strLetraPushPin, _
        strTitulo, _
        strSubTitulo, _
        strLatGPS, _
        strLgtGPS As String


    ' não há erros (para já) e ir buscar a página com o template
    ' carregar os pontos todos para afixar
        
    Call logMe("Form_Load", "viewNewGPS")
    
    Me.ctlWebBrowser.Object.Silent = True
    Set m_WebBrowser = ctlWebBrowser.Object
    m_WebBrowser.Navigate "c:\temp\map.html"
    
    dbl_latGPS = Forms![_commonVariables]![LatGPS]
    dbl_lgtGPS = Forms![_commonVariables]![LgtGPS]
    strLatGPS = Format(dbl_latGPS, "###.0000000")
    strLgtGPS = Format(dbl_lgtGPS, "###.0000000")

    strLetraPushPin = Forms![_commonVariables]![letraPushPin]
    strTitulo = Forms![_commonVariables]![codigoPonto]
    strSubTitulo = Forms![_commonVariables]![TipoPonto]

    Debug.Print "lat:" & strLatGPS
    Debug.Print "lon:" & strLgtGPS
    Debug.Print "letra:" & strLetraPushPin
    Debug.Print "tit:" & strTitulo
    Debug.Print "subtit:" & strSubTitulo
    'mostrar o pushpin
    Debug.Print strLatGPS & " / " & strLgtGPS & "/" & strLetraPushPin & "/" & strTitulo & "/" & strSubTitulo
    
    
    InvokeJavaScript "try { addPushpin(" + strLatGPS + ", " + strLgtGPS + ",'" + strLetraPushPin + "','" + strTitulo + "','" + strSubTitulo + "''); } catch(err) { alert(err); }"
    'InvokeJavaScript "addPushpin(strLatGPS, strLgtGPS, strLetraPushPin, strTitulo, strSubTitulo);"
    'InvokeJavaScript "alert('ok');"
    'InvokeJavaScript "addPushpin(" + strLatGPS + ", " + strLgtGPS + "," + strLetraPushPin + "," + strTitulo + "," + strSubTitulo + ");"
'InvokeJavaScript "alert(typeof addPushpin);"

    
End Sub

Open in new window




btw, by mistake, when I first tried, I had commented the forts "invoke" and NOT commented the

InvokeJavaScript "alert(typeof addPushpin);

and was getting the same error.
map---old.html
map.html
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41896717
could you try this :
m_WebBrowser.Document.InvokeJavaScript("addPushpin(11,-15,'X','PDA.36G017','Fonte')")

Open in new window

0
 

Author Comment

by:jirdeaid
ID: 41897048
I did, but got an error:


ss1
and

Screen-Shot-2016-11-22-at-07.09.23.png
0
 

Author Comment

by:jirdeaid
ID: 41898631
Hi.... any news?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41898646
I need to recreate your environment application to see what happen. What is your MS Access version and what is your OS ?
0
 

Author Comment

by:jirdeaid
ID: 41898666
Ok.

I am sending my db just for the sake of context. I am using ms/access 2016 (Office 365) and windows 10 pro.

The form in question is "viewNewGPS" which is launched by the button "btn_viewGPS" in form "marcacoesTabancaSF".

I am working in Guinea-Bissau and this is a development I am doing, on my own, to help managing rural water supply, showing that we may be able to show some GIS capabilities without major investments.

What I need is the capability to show, in a map, some points to be managed (hospital, borehole, pump, etc...)

I am following this site from Microsoft (http://www.bing.com/api/maps/sdk/mapcontrol/isdk#displayInfoboxOnClickPushpin+JS ) as it contains code for all my immediate needs:

--- show and label a single pushpin (I am trying this as a first step)
--. show and label  several pushpins (that's the one I need)
-- get pushpin data (so I can set Lat/Lon from map)
-- display infobox when pushpin is pressed
-- use a pushpin designed by me with transparency

Although this comes from my personal purse, I could (considering the costs of EE) even consider to pay someone to help me on this journey.
map.html
0
 

Author Comment

by:jirdeaid
ID: 41898668
the database is attached...
siresh-gb.03.16.accdb
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41898688
ok thanks, nice project. I will be able to work on this in some hours, don't be "hurt" :D if I don't give you news until some hours
0
 

Author Comment

by:jirdeaid
ID: 41899646
Ok great many thanks! (I am living in guinea-bissau and 'ot was a pretty heavy day... soi I could also not respondo to you...
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41899839
To fix, I use my localhost web server because, I was, for security reason, not able to open the map.html from c:\temp
https://httpd.apache.org/docs/current/en/platform/windows.html

'm_WebBrowser.Navigate "http://localhost/map.html"
m_WebBrowser.Navigate "http://localhost/map.html"

Open in new window


Also before running the code with InvokeJavascript, I need to be sure the Web Browser Control finish to load its content, especially the Bing Map plugin and basically head, body of the HTML page alias map.html
Done with the following just before InvokeJavascript

    Do While m_WebBrowser.ReadyState <> READYSTATE_COMPLETE
        DoEvents
    Loop

Open in new window


Also I change the addPushpin to a very basic code and also the page.
The page did not had a <div id='mapDiv'></div> so no way to display the map inside...
You need to try first with working code before trying to do your own :

map.html
<html>
<head>
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
<script type="text/javascript">

      var map = null;

      function addPushpin(strLatGPS, strLgtGPS, strLetraPushPin, strTitulo, strSubTitulo) {
		
         map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), {credentials: "!!!!!!!!!! PUT YOUR REAL KEY HERE !!!!!!!"});

         var center = new Microsoft.Maps.Location(strLatGPS*1, strLgtGPS*1);
         var pin = new Microsoft.Maps.Pushpin(center, {text: strLetraPushPin}); 
         map.entities.push(pin);
         map.setView({center:center});     

      }

</script>
</head>
<body>
<div id='mapDiv'></div>
</body>
</html>

Open in new window

0
 

Author Comment

by:jirdeaid
ID: 41900908
could just got to your reply right now...

Ok... I replaced my code that now is:


  Dim dbl_latGPS, dbl_lgtGPS As Double
    Dim strLetraPushPin, _
        strTitulo, _
        strSubTitulo, _
        strLatGPS, _
        strLgtGPS As String


    ' não há erros (para já) e ir buscar a página com o template
    ' carregar os pontos todos para afixar
        
    Call logMe("Form_Load", "viewNewGPS")
    
    Me.ctlWebBrowser.Object.Silent = True
    Set m_WebBrowser = ctlWebBrowser.Object
    m_WebBrowser.Navigate "c:\temp\map.html"
    
    dbl_latGPS = Forms![_commonVariables]![LatGPS]
    dbl_lgtGPS = Forms![_commonVariables]![LgtGPS]
    strLatGPS = Format(dbl_latGPS, "###.0000000")
    strLgtGPS = Format(dbl_lgtGPS, "###.0000000")

    strLetraPushPin = Forms![_commonVariables]![letraPushPin]
    strTitulo = Forms![_commonVariables]![codigoPonto]
    strSubTitulo = Forms![_commonVariables]![TipoPonto]

    Debug.Print "lat:" & strLatGPS
    Debug.Print "lon:" & strLgtGPS
    Debug.Print "letra:" & strLetraPushPin
    Debug.Print "tit:" & strTitulo
    Debug.Print "subtit:" & strSubTitulo
    'mostrar o pushpin
    Debug.Print strLatGPS & " / " & strLgtGPS & "/" & strLetraPushPin & "/" & strTitulo & "/" & strSubTitulo
    
     Do While m_WebBrowser.ReadyState <> READYSTATE_COMPLETE
        DoEvents
    Loop
    
    InvokeJavaScript "try { addPushpin(" + strLatGPS + ", " + strLgtGPS + ",'" + strLetraPushPin + "','" + strTitulo + "','" + strSubTitulo + "''); } catch(err) { alert(err); }"
    'InvokeJavaScript "addPushpin(strLatGPS, strLgtGPS, strLetraPushPin, strTitulo, strSubTitulo);"
    'InvokeJavaScript "alert('ok');"
    'InvokeJavaScript "addPushpin(" + strLatGPS + ", " + strLgtGPS + "," + strLetraPushPin + "," + strTitulo + "," + strSubTitulo + ");"
    'InvokeJavaScript "alert(typeof addPushpin);"
    'm_WebBrowser.Document.InvokeJavaScript ("addPushpin(11,-15,'X','PDA.36G017','Fonte')")

Open in new window

   
and replaced the map.html with;
<head>
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
<script type="text/javascript">

      var map = null;

      function addPushpin(strLatGPS, strLgtGPS, strLetraPushPin, strTitulo, strSubTitulo) {
		
         map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), {credentials: "Cf3MMNpX7b5i5LAz0bI8~uB-e4p_-zrIZGk__sH-X9A~Ap8kmAfgzvmdDuT7s_251ytuyokEkGa-8ey8uExMxF0ZmFAHuw-mjEQYkPwWrjO"});

         var center = new Microsoft.Maps.Location(strLatGPS*1, strLgtGPS*1);
         var pin = new Microsoft.Maps.Pushpin(center, {text: strLetraPushPin}); 
         map.entities.push(pin);
         map.setView({center:center});     

      }

</script>
</head>
<body>
<div id='mapDiv'></div>
</body>
</html>

Open in new window




and got:

Screen-Shot-2016-11-24-at-21.01.06.png
and

then the page after a few moments of "computing" goes white...
Screen-Shot-2016-11-24-at-21.01.14.png
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41900930
You got the access denied for the same reason as me, you must use a web server like Apache HTTPD (I give you a link in my previous question).
Also your web page is not complete, your start with <head> when mine start with <html>
0
 

Author Comment

by:jirdeaid
ID: 41901219
Okay. But that's a bit weird for me. I was using miniweb and had the page there and then, on another track. a solution was found  (https://www.experts-exchange.com/questions/28981587/using-web-browser-with-BING.html#a41894133)  without it so I jumped in because I did not have to install a webserver on all the client computers. It worked on the trial small db (it just had 1 button and the webcontrol) and then, when I moved back to the main DB restarted the headaches.

Ok - I'll rework from your advice, but, has I will have a pretty heavy day, only by the end of the day I will be able to show you the results.

/joao
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41901447
please not you don't need one web server by user. If you already have one, you can host your page to it. just be sure you can successflly open the page in a webbrowser.
the current issue is you MUSt wait the page to load before calling the script.
to do that, the only method I found is to use "Do While m_WebBrowser.ReadyState <> READYSTATE_COMPLETE"
0
 

Author Comment

by:jirdeaid
ID: 41902295
'got a situation. I am really sorry to bug you but I am a bit at dead ends...

It took a while, as I also got malaria and then couldn't work for half  a day...

well

I started my miniweb and put the mp.html page there. The page is annex to this message.

then I modified my code accordingly. My code now looks for the page on the server:

Private Sub Form_Load()

    Dim dbl_latGPS, dbl_lgtGPS As Double
    Dim strLetraPushPin, _
        strTitulo, _
        strSubTitulo, _
        strLatGPS, _
        strLgtGPS As String


    ' não há erros (para já) e ir buscar a página com o template
    ' carregar os pontos todos para afixar
        
    Call logMe("Form_Load", "viewNewGPS")
    
    Me.ctlWebBrowser.Object.Silent = True
    Set m_WebBrowser = ctlWebBrowser.Object
    'm_WebBrowser.Navigate "c:\temp\map.html"
     m_WebBrowser.Navigate ("http:///10.211.55.3:8000/map.html")
    dbl_latGPS = Forms![_commonVariables]![LatGPS]
    dbl_lgtGPS = Forms![_commonVariables]![LgtGPS]
    strLatGPS = Format(dbl_latGPS, "###.0000000")
    strLgtGPS = Format(dbl_lgtGPS, "###.0000000")

    strLetraPushPin = Forms![_commonVariables]![letraPushPin]
    strTitulo = Forms![_commonVariables]![codigoPonto]
    strSubTitulo = Forms![_commonVariables]![TipoPonto]

    Debug.Print "lat:" & strLatGPS
    Debug.Print "lon:" & strLgtGPS
    Debug.Print "letra:" & strLetraPushPin
    Debug.Print "tit:" & strTitulo
    Debug.Print "subtit:" & strSubTitulo
    'mostrar o pushpin
    Debug.Print strLatGPS & " / " & strLgtGPS & "/" & strLetraPushPin & "/" & strTitulo & "/" & strSubTitulo
    
     Do While m_WebBrowser.ReadyState <> READYSTATE_COMPLETE
        DoEvents
    Loop
    
    InvokeJavaScript "try { addPushpin(" + strLatGPS + ", " + strLgtGPS + ",'" + strLetraPushPin + "','" + strTitulo + "','" + strSubTitulo + "''); } catch(err) { alert(err); }"
    'InvokeJavaScript "addPushpin(strLatGPS, strLgtGPS, strLetraPushPin, strTitulo, strSubTitulo);"
    'InvokeJavaScript "alert('ok');"
    'InvokeJavaScript "addPushpin(" + strLatGPS + ", " + strLgtGPS + "," + strLetraPushPin + "," + strTitulo + "," + strSubTitulo + ");"
    'InvokeJavaScript "alert(typeof addPushpin);"
    'm_WebBrowser.Document.InvokeJavaScript ("addPushpin(11,-15,'X','PDA.36G017','Fonte')")

    
End Sub

Open in new window



and I back to the original problem:

Screen-Shot-2016-11-26-at-12.10.10.png

then, to test again, I came back toa previous version, that I tested on an independent DB, used only for testing, with a different "map.html",  called "mappage.html", which I also attach..The code then is:

    Dim strLetraPushPin, _
        strTitulo, _
        strSubTitulo, _
        strLatGPS, _
        strLgtGPS As String


    ' não há erros (para já) e ir buscar a página com o template
    ' carregar os pontos todos para afixar
        
    Call logMe("Form_Load", "viewNewGPS")
    
    Me.ctlWebBrowser.Object.Silent = True
    Set m_WebBrowser = ctlWebBrowser.Object
    'm_WebBrowser.Navigate "c:\temp\map.html"
     m_WebBrowser.Navigate ("http:///10.211.55.3:8000/mappage.html")
    dbl_latGPS = Forms![_commonVariables]![LatGPS]
    dbl_lgtGPS = Forms![_commonVariables]![LgtGPS]
    strLatGPS = Format(dbl_latGPS, "###.0000000")
    strLgtGPS = Format(dbl_lgtGPS, "###.0000000")

    strLetraPushPin = Forms![_commonVariables]![letraPushPin]
    strTitulo = Forms![_commonVariables]![codigoPonto]
    strSubTitulo = Forms![_commonVariables]![TipoPonto]

    Debug.Print "lat:" & strLatGPS
    Debug.Print "lon:" & strLgtGPS
    Debug.Print "letra:" & strLetraPushPin
    Debug.Print "tit:" & strTitulo
    Debug.Print "subtit:" & strSubTitulo
    'mostrar o pushpin
    Debug.Print strLatGPS & " / " & strLgtGPS & "/" & strLetraPushPin & "/" & strTitulo & "/" & strSubTitulo
    
     Do While m_WebBrowser.ReadyState <> READYSTATE_COMPLETE
        DoEvents
    Loop
    
    'InvokeJavaScript "try { addPushpin(" + strLatGPS + ", " + strLgtGPS + ",'" + strLetraPushPin + "','" + strTitulo + "','" + strSubTitulo + "''); } catch(err) { alert(err); }"
    'InvokeJavaScript "addPushpin(strLatGPS, strLgtGPS, strLetraPushPin, strTitulo, strSubTitulo);"
    'InvokeJavaScript "alert('ok');"
    'InvokeJavaScript "addPushpin(" + strLatGPS + ", " + strLgtGPS + "," + strLetraPushPin + "," + strTitulo + "," + strSubTitulo + ");"
    'InvokeJavaScript "alert(typeof addPushpin);"
    'm_WebBrowser.Document.InvokeJavaScript ("addPushpin(11,-15,'X','PDA.36G017','Fonte')")

    
End Sub

Open in new window


It is a very similar code; I just address the different page on the server and do not  invoke the javascript and it functions:

Screen-Shot-2016-11-26-at-12.15.04.png

However, please note  the, as I pointed, on another track that I also initiated https://www.experts-exchange.com/questions/28981587/using-web-browser-with-BING.html#a41894133
a solution by stephen hoffman was proposed WITHOUT using any server
I quote:

"The key is: there is no need for dynamic files. You load your HTML and necessary files only once. The rest is injected either into the DOM directly or by using JavaScript functions which are already part of your file:"

So Stephan sent out a working DB without server (attached and it is on the track as well - name is BINGMAPS) and I closed the question. Can you please verify?


So, after verifying, I migrated the code from Stephan to my code above and started to getting new problems. I do strongly believe that I am wrongly invoking javascript because I had to migrate from the working BINGMAPS (that contained two buttons, a "load" button that must be automatic  and a "set 0/0 button" that actually invokes the code.

Of course, I am ready to go either way (well, the solution of not needing to use a specific webserver is the best one (can I host it on a site I own? - how can I put it there?) , but I really need help to get over this.

Any suggestion?


/joao
map.html
mappage.html
BingMaps.accdb
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 82

Expert Comment

by:leakim971
ID: 41902301
did you understood what I mean by "waiting the page to load" ?
0
 

Author Comment

by:jirdeaid
ID: 41902305
hopefully yes. This is why I pasted in your code:

Do While m_WebBrowser.ReadyState <> READYSTATE_COMPLETE
        DoEvents
    Loop

was I wrong?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41902306
OK, so I checked the answer from the previous question and I see this :
Private Sub btnCenter_Click()

  InvokeJavaScript "addPushpin(0, 0, 'C', 'Middle of the Earth', 'Maybe dragons.');"

End Sub

Open in new window


so here we don't run the InvokeJavascript as soon we load the page.
the user need to click on a button.

now, on this question, you want to run it just after asking the minibrowser to load the page.
previous question : you let the page time to load before InvokeScript
current question, you run immediately InvokeScript not giving the minibrowser the time to load the page

you should put back map.html, it worked fine on my side. you must find why it did not work for you
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41902311
try this :
m_WebBrowser.Navigate ("http:///10.211.55.3:8000/map.html?t=1233")

1233 is a random number to force the browser to not use a cached version
0
 

Author Comment

by:jirdeaid
ID: 41902316
Ok. I'll do it right now!
1
 

Author Comment

by:jirdeaid
ID: 41902322
getting exactly the same error..

and I have corrected the code:

Private Sub Form_Load()

    Dim dbl_latGPS, dbl_lgtGPS As Double
    Dim strLetraPushPin, _
        strTitulo, _
        strSubTitulo, _
        strLatGPS, _
        strLgtGPS As String


    ' não há erros (para já) e ir buscar a página com o template
    ' carregar os pontos todos para afixar
        
    Call logMe("Form_Load", "viewNewGPS")
    
    Me.ctlWebBrowser.Object.Silent = True
    Set m_WebBrowser = ctlWebBrowser.Object
    'm_WebBrowser.Navigate "c:\temp\map.html"
    'm_WebBrowser.Navigate ("http:///10.211.55.3:8000/mappage.html")
    m_WebBrowser.Navigate ("http:///10.211.55.3:8000/map.html?t=1233")
    dbl_latGPS = Forms![_commonVariables]![LatGPS]
    dbl_lgtGPS = Forms![_commonVariables]![LgtGPS]
    strLatGPS = Format(dbl_latGPS, "###.0000000")
    strLgtGPS = Format(dbl_lgtGPS, "###.0000000")

    strLetraPushPin = Forms![_commonVariables]![letraPushPin]
    strTitulo = Forms![_commonVariables]![codigoPonto]
    strSubTitulo = Forms![_commonVariables]![TipoPonto]

    Debug.Print "lat:" & strLatGPS
    Debug.Print "lon:" & strLgtGPS
    Debug.Print "letra:" & strLetraPushPin
    Debug.Print "tit:" & strTitulo
    Debug.Print "subtit:" & strSubTitulo
    'mostrar o pushpin
    Debug.Print strLatGPS & " / " & strLgtGPS & "/" & strLetraPushPin & "/" & strTitulo & "/" & strSubTitulo
    Debug.Print Now()
    Do While m_WebBrowser.ReadyState <> READYSTATE_COMPLETE
        DoEvents
    Loop
    Debug.Print Now()
    InvokeJavaScript "try { addPushpin(" + strLatGPS + ", " + strLgtGPS + ",'" + strLetraPushPin + "','" + strTitulo + "','" + strSubTitulo + "''); } catch(err) { alert(err); }"
    'InvokeJavaScript "addPushpin(strLatGPS, strLgtGPS, strLetraPushPin, strTitulo, strSubTitulo);"
    'InvokeJavaScript "alert('ok');"
    'InvokeJavaScript "addPushpin(" + strLatGPS + ", " + strLgtGPS + "," + strLetraPushPin + "," + strTitulo + "," + strSubTitulo + ");"
    'InvokeJavaScript "alert(typeof addPushpin);"
    'm_WebBrowser.Document.InvokeJavaScript ("addPushpin(11,-15,'X','PDA.36G017','Fonte')")

    
End Sub

Open in new window


any ideas?
0
 

Author Comment

by:jirdeaid
ID: 41902323
I can put the two buttons as a workaround...
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 500 total points
ID: 41902327
I can put the two buttons as a workaround...
lol, yes I know :D
try to open the map page in your browser using http:///10.211.55.3:8000/map.html to confirm it work fine
also try this one in your browser (don't forget to replace your creds) :
<html>
<head>
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
<script type="text/javascript">

      var map = null;

      function addPushpin(strLatGPS, strLgtGPS, strLetraPushPin, strTitulo, strSubTitulo) {
		
         map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), {credentials: "PUT VALID CREDS HERE"});

         var center = new Microsoft.Maps.Location(strLatGPS*1, strLgtGPS*1);
         var pin = new Microsoft.Maps.Pushpin(center, {text: strLetraPushPin}); 
         map.entities.push(pin);
         map.setView({center:center});     

      }

      if(window.addEventListener)
      		window.addEventListener("load", function() { addPushpin(11,-15,'X','PDA.36G017','Fonte'); }, false);
      else
      		window.attachEvent("onload", function() { addPushpin(11,-15,'X','PDA.36G017','Fonte'); });      	

</script>
</head>
<body>
<div id='mapDiv'></div>
</body>
</html>

Open in new window


if the boht pages work fine in your browser, go back to the previous one using the following line and not the try catch one:
m_WebBrowser.Document.InvokeJavaScript ("addPushpin(11,-15,'X','PDA.36G017','Fonte')")

again, it work fine for me, it should work fine for you
0
 

Author Comment

by:jirdeaid
ID: 41902333
Well --- the first one yields a white page now matter how many times I refresh it


the second one yields w zoomed out map, in the correct point, but states that my credentials are incorrect (!).And I took some time to reconfirm that they are correct!
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41902337
the white page is normal as we don't run the code
the second one run the code just like the InvokeScript do it on MS Access
so put the first one with a valid key (to confirm open the second one doing the job with your browser) and try :
Do While m_WebBrowser.ReadyState <> READYSTATE_COMPLETE
      DoEvents
Loop
m_WebBrowser.Document.InvokeJavaScript ("addPushpin(11,-15,'X','PDA.36G017','Fonte')")

Open in new window

0
 

Author Comment

by:jirdeaid
ID: 41902362
ok

now we've got 2issues:

a) got an error:
Screen-Shot-2016-11-26-at-14.45.49.png

Screen-Shot-2016-11-26-at-14.46.02.png



b) the key I have from bing maps yields the "invalid key". can it be the application name?
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 500 total points
ID: 41902366
sorry, my bad, use the right one :
Do While m_WebBrowser.ReadyState <> READYSTATE_COMPLETE
      DoEvents
Loop
InvokeJavaScript ("addPushpin(11,-15,'X','PDA.36G017','Fonte')")

Open in new window


b) nope, I found random one on google and all work on your page...
0
 

Author Comment

by:jirdeaid
ID: 41902369
ok. so I'll google for a key... instead of using the one provided by microsoft (stupid, no?)

here is what I have got: (just the zoom level is wrong)


Screen-Shot-2016-11-26-at-14.55.36.png
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41902370
great, for the zoom, add the style from your other/orginal page :
in map.html, replace :
<div id='myMap'>
by :
<div id='myMap' style='width: 100vw; height: 100vh;'>
0
 

Author Comment

by:jirdeaid
ID: 41902372
I see no difference... are you sure?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41902374
add zoom:10 for example just after creds

map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), {credentials: "PUT VALID CREDS HERE", zoom:10});

Open in new window

0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 41902376
now, you have a map launch from MS Access but the all parameters are static, let's go back to the dynamic version and use this :
/!\ replace the current one by this one, there's an extra quote at the end...

InvokeJavaScript "addPushpin(" + strLatGPS + ", " + strLgtGPS + " ,'" + strLetraPushPin + "','" + strTitulo + "' ,'" + strSubTitulo + "');"

Open in new window

0
 

Author Comment

by:jirdeaid
ID: 41902384
Ok.

It looks that it is starting to work.


but the zoom does not. could it be the problem with the credentials? I have just renewed them, downloaded them but I am still having the same invalid key...

one step at a time!
Screen-Shot-2016-11-26-at-15.22.51.png
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41902387
0
 

Author Comment

by:jirdeaid
ID: 41902393
yes...

But I was editing the wrong map.html and I was using tow commas.... (!)

now it shows like this:


Screen-Shot-2016-11-26-at-15.34.37.png

it looks that only the problem with credentials remains.

I am sending you the map.html so you may check. Could it be the syntax?
map.html
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41902406
I don't know about the creds... Just request a new key.
The page is fine for me.
0
 

Author Comment

by:jirdeaid
ID: 41902410
Ok. let me close this with a HUGE TERA thanks
1
 

Author Closing Comment

by:jirdeaid
ID: 41902420
Thanks a lot. Now I need to clean up my code (I already saw some malfunction) as no title/subtitle.).

For sure I will need further help. Just hope that you will be available then.


finally: I would rather store the map.thml on my site then depend on miniweb to have it. How can I do it?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41902431
I think it's possible to use c:\temp\map.html maybe figthing with OS and default browser security... Lot of work when you've free web hosting available.

I'm not sur you can store the whole bing/Google map service on your own site but I'm pretty sure you can find some application allowing that
0
 

Author Comment

by:jirdeaid
ID: 41902496
no... I was just wanting to store the page. ...
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41902510
I picked a random one :
https://getforge.com/pricing
0
 

Author Comment

by:jirdeaid
ID: 41902520
I fail to understand; is this https://getforge.com/pricing for getting a key?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41902526
A free hosting for the map.html
0
 

Author Comment

by:jirdeaid
ID: 41902532
ah! thanks!!!!

but I do already have a site. I just need to understand how to put a page there, as I never didi before...
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41902533
Usually it's done by FTP, you just need your credentials. Google "ftp you-provider-name"
0
 

Author Comment

by:jirdeaid
ID: 41902539
Ok! thanks again.

I will open a new question, so you may earn more points.

The "map.html" page that you provided me, had just the code for the "text" part, but not for the title and subtitle.

So I corrected it but I am surely wrongdoing so it crashes again with the same 800xxxx error.  Maybe you'll be able to help on that one as well
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41902545
That should do it :
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>pushpinLabelsHTML</title>
		<script type="text/javascript" src="http://www.bing.com/api/maps/mapcontrol?branch=release&callback=loadMapScenario" async defer></script>
		<script type="text/javascript">
			var map;

			function loadMapScenario() {
				var options = { credentials: "AtmgIDsskKTlLBNr_LUOcdlK9ZFu3ZPBCdN_o5OSIh01ShsuR4mmzZAuD3PvGyaQ", zoom:10 };
				map = new Microsoft.Maps.Map(document.getElementById("myMap"), options);
			}

			function addPushpin(strLatGPS, strLgtGPS, strLetraPushPin, strTitulo, strSubTitulo) {
				var center = new Microsoft.Maps.Location(strLatGPS*1, strLgtGPS*1);
				var pin = new Microsoft.Maps.Pushpin(center, {text: strLetraPushPin, title: strTitulo, subTitle: strSubTitulo}); 
				map.entities.push(pin);
				map.setView({center:center});  			
            }

		</script>
	</head>
	<body> 		
		<div id="myMap" style="width: 100vw; height: 100vh;"></div>
	</body>
</html>

Open in new window

0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now