Solved

WebBrowser Control - ms/ACCESS

Posted on 2016-10-09
9
32 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:jirdeaid
  • 4
  • 3
  • 2
9 Comments
 
LVL 19
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:jirdeaid
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 19
ID: 41835937
do you have a KEY to use bing maps? You may want to use google maps instead ...
0
 

Author Comment

by:jirdeaid
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 49

Accepted Solution

by:
Gustav Brock earned 250 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 19

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 250 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 49

Expert Comment

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

/gustav
0
 
LVL 19
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:jirdeaid
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

760 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

22 Experts available now in Live!

Get 1:1 Help Now