Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ust html in ms/access WebBrowswer

Posted on 2016-10-11
11
Medium Priority
?
85 Views
Last Modified: 2016-11-16
In order to have control  of the parameters that I need to send to google maps (to be shown embedded in a control on a web form, according to Google Maps, I need to be able to "store" either a javascript or a html script in it, for which I can find no manner to do.

By googling a bit, I found the following suggestion on stack exchange:

Well, I decided to use the ActiveX WebBrowser control instead of the native WebBrowser for Access 2010/2013 since the former accepts the html string and formats the document correctly by using the write property of the document.

QUOTE
With Me.WebBrowser6.Object
    .Navigate2 "about:blank"
    .Document.write rst.Fields(2)
    .Refresh
End With

UNQUOTE

but nothing happens

can anyone help me?
0
Comment
Question by:João serras-pereira
  • 6
  • 4
11 Comments
 
LVL 36

Expert Comment

by:ste5an
ID: 41840407
Well, I decided to use the ActiveX WebBrowser control instead of the native WebBrowser for Access 2010/2013 since the former accepts the html string and formats the document correctly by using the write property of the document.

D'oh? WebBrowser can do this also.

But .Refresh is not necessary nor does it something useful here.
0
 

Author Comment

by:João serras-pereira
ID: 41840502
The question is: How does it?
0
 
LVL 36

Accepted Solution

by:
ste5an earned 2000 total points
ID: 41840526
Misunderstood your post. Use ActiveX instead:

With Me.WebBrowser6.Object
     .Navigate "about:blank"
     .Document.write "<h1>Test</h1>
 End With

Open in new window

Q28975670.accdb
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 

Author Comment

by:João serras-pereira
ID: 41840631
Thanks a lot.

A thanks for the example.

So, it I replace "<h1>Test<h1> and using the proper CR chars, wuth

<!DOCTYPE html>
<html>
    <head>
        <title>createPushpinFromCanvasHTML</title>
        <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
    </head>
    <body>
        <div id='printoutPanel'></div>
       
        <div id='myMap' style='width: 100vw; height: 100vh;'></div>
        <script type='text/javascript'>
            function loadMapScenario() {
                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();
                }
               
            }
        </script>
        <script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?branch=release&callback=loadMapScenario' async defer></script>
    </body>
</html>

will it work?

by
0
 
LVL 36

Expert Comment

by:ste5an
ID: 41840713
Basically, yes. But the question is: Why not storing this as local HTML file and distributing it with your database file?
0
 

Author Comment

by:João serras-pereira
ID: 41840751
You are right!

My problem is "theoretically" quite simple:

I want to show some points for which, in my database, I do have GPS coordinates some pushpins, an text that depend on the type of point. Like this:

PointRef     Lat    Lon   Type        Text
r1                 La1   Lo1   Ty1          Txt1
r2                 La2   Lo1   Ty2          Txt2
r3                 La2   Lo1   Ty2          Txt2


So I want to plot in a map, Google Maps or Bing those 3 points. The map is to be shown inside the WebBrowser.

the code I have sent you is exactly the code that microsoft uses as example to use Bing:

http://www.bing.com/api/maps/sdk/mapcontrol/isdk#createPushpinFromCanvas+JS

so it easy for me just to alter it to my specific case, but I can also use Google Maps.

what would be your suggestion?
0
 
LVL 36

Expert Comment

by:ste5an
ID: 41840793
Pretty simple: Inject the data.

Create JavaScript function to take the data as parameter and call it from Access.

Apparently I'm writing an article about it. So when you can wait some days..
0
 

Author Comment

by:João serras-pereira
ID: 41840831
Well... I don't know anything about javascript, so it is, right now, beyond my capabilities. However, if your article, is able to provide easy examples, I will follow it immediately! - how can I know about it? (my email?:joao.serras.pereora@ware.pt)

anyway, I am sending you the database with the "new" code that I have sent you, but it does not work: a totally white page is what is shown... I am sure that the error is mine, and if I can't get to a solution I'll ask a new question...

I am closing this page
Q28975670.accdb
0
 

Author Comment

by:João serras-pereira
ID: 41840835
THANKS!
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 41885355
This is because IE is the browser called and it has to run a local script in low security mode. It can be a file you open, or it can be dynamic using strMap:

    WebBrowser.Navigate "about:Blank"
    WebBrowser.Document.Write strMap

but still, the script security will kick in and block.

You may have to run the script off a file from a (local) web server to get passed the strict security.

/gustav
0
 

Author Closing Comment

by:João serras-pereira
ID: 41890948
thanks for the help!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

971 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