Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

WebBrowser Control - ms/ACCESS

Posted on 2016-10-09
9
Medium Priority
?
129 Views
Last Modified: 2016-11-13
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
Comment
Question by:João serras-pereira
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 22
ID: 41835916
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
 

Author Comment

by:João serras-pereira
ID: 41835935
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
 
LVL 22
ID: 41835937
do you have a KEY to use bing maps? You may want to use google maps instead ...
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 

Author Comment

by:João serras-pereira
ID: 41835948
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
 
LVL 52

Accepted Solution

by:
Gustav Brock earned 1000 total points
ID: 41885358
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
 
LVL 22

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 1000 total points
ID: 41885368
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
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 41885375
Easier or not, the behaviour is the same as they both call IE.

/gustav
0
 
LVL 22
ID: 41885378
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
 

Author Closing Comment

by:João serras-pereira
ID: 41885425
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

618 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