Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

WebBrowser Control - ms/ACCESS

Im am developing a small ms/access application. I have a ms/access 2016 database with Lat/Lon coordinates for several types of points and, for them, I want to show, on the web browser, where they are and what they are, using colours and pushpin types.
 
I am already able to center the map where it needs, provide appropriate zoom levels, etc. setting the control source of the webbrowser to:
"http://bing.com" & "/maps/embed/viewer.aspx?cp=" & [textGPS] & "&lvl=12&dir=90&sty=r&w=600&h=600"

I also learned the there is a Bing Maps V8 Web Control that provides the needed functionality as long as I am able to somehow develop programs in JavaScript/HTML/TypeScript for which Microsoft already proves samples that are good enough to me as they contain the today's required functionality (e.g.http://www.bing.com/api/maps/sdk/mapcontrol/isdk#createPushpinFromCanvas+JS) .

The problem now is, how do I, in the WebBrowser control, set up the javascript or html to run. Documentation mentions that we should use the  “DocumentText” property of the WebBrowser Control. But this property does no show...

How to do it?
0
João serras-pereira
Asked:
João serras-pereira
  • 4
  • 3
  • 2
2 Solutions
 
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
here is a start for you:
Private Sub cmdTest_Click()
'161009 strive4peace
'NEEDS Reference to Microsoft HTML Object Library
   Dim oDocument As HTMLDocument
   Dim oElement As HTMLHtmlElement
   
   Dim sID As String
   Set oDocument = Me.WebBrowser0.Object.Document
   For Each oElement In oDocument.all
      sID = oElement.id
      If sID <> "" Then
         Debug.Print sID, oDocument.getElementById(sID).outerHTML
      End If
   Next oElement

End Sub

Open in new window

Access -- reference Microsoft HTML Object Library
0
 
João serras-pereiraAuthor Commented:
Hi

I am trying to understand your suggestion...

The suggested code is:

   Dim oDocument As HTMLDocument
   Dim oElement As HTMLHtmlElement
   
   Dim sID As String
   Set oDocument = Me.WebBrowser0.Object.Document
   For Each oElement In oDocument.all
      sID = oElement.id
      If sID <> "" Then
         Debug.Print sID, oDocument.getElementById(sID).outerHTML
      End If
   Next oElement

So, if I correctly understand, we have an HTML document, internal to the app that is set to the value of the WebBrowser container.

If any of the elements of the WebBrowser are not empty they get printed out (I guess that the rationale is to find which oDocument element contains the , but, the method debug.print is not printing anything...




var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
    credentials: 'Your Bing Maps Key'
});
var pushpin = new Microsoft.Maps.Pushpin(map.getCenter(), {
    icon: createRedArrow(45),
    anchor: new Microsoft.Maps.Point(12, 12)
});
map.entities.push(pushpin);
function createRedArrow(heading) {
    var c = document.createElement('canvas');
    c.width = 24;
    c.height = 24;
    var ctx = c.getContext('2d');
    // Offset the canvas such that we will rotate around the center of our arrow
    ctx.translate(c.width * 0.5, c.height * 0.5);
    // Rotate the canvas by the desired heading
    ctx.rotate(heading * Math.PI / 180);
    //Return the canvas offset back to it's original position
    ctx.translate(-c.width * 0.5, -c.height * 0.5);
    ctx.fillStyle = '#f00';
    // Draw a path in the shape of an arrow.
    ctx.beginPath();
    ctx.moveTo(12, 0);
    ctx.lineTo(5, 20);
    ctx.lineTo(12, 15);
    ctx.lineTo(19, 20);
    ctx.lineTo(12, 0);
    ctx.closePath();
    ctx.fill();
    ctx.stroke();
    // Generate the base64 image URL from the canvas.
    return c.toDataURL();
}
0
 
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
do you have a KEY to use bing maps? You may want to use google maps instead ...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
João serras-pereiraAuthor Commented:
Nope, I still do not have a key. I didn't looked for it.  Currently, it shows almost what I want, but no pushpins or text that I can send through the Web Browser so I the user may see what he/she needs.

Anyway I am really KEEN on using Google Maps (although images are much worse, believe it or not).
I just don't know how to open a google map in the WebBrowser and set the parameters I want (actually just a few pushpins whose type depend on the type of object I need to represent and small text.

Do you know how to do it?
0
 
Gustav BrockCIOCommented:
Using Google Maps will not change anything as your trouble is the strict security having IE running scripts in local files.

Your simplest option to circumvent this is probably to open a page stored at a web server passing the parameters you need.

/gustav
0
 
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
There is more than one web browser control -- I find the one on the Active Control list easier to use.
Access -- insert web browser controlOnce the URL is constructed,  use the Navigate method to your page. For instance:
   me.webBrowser_controlname.Navigate sURL

Open in new window

Here is an example that shows how to embed JavaScript. I have not dug into it deep enough to know which web browser control is used.
http://www.dymeng.com/browseEmbed/
0
 
Gustav BrockCIOCommented:
Easier or not, the behaviour is the same as they both call IE.

/gustav
0
 
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
they are a little different -- the first web browser control (the 7th tool shown in the controls group)  does not have a Navigate method.  Not sure what is used instead.
0
 
João serras-pereiraAuthor Commented:
well I am closing this question as there is a similar stream on other one. But is remains: how do I do it?
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now