X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Receiving Data From Jack Leach's Browseembed, Access 2010    
Steve Waring
post May 16 2019, 06:55 AM

Posts: 3
Joined: 16-May 19

Having looked at https://dymeng.com/browseembed-html5javascr...ccess-projects/ it looks like exactly what I would like to receive events from an embeded Microsoft Bing map. I'd be able to use it to pick up the latitude and longitude of a dragged map.

There is quite a bit to the setup, so taking baby steps, I have set up an Access DB to simply create the move mouse example in the documentation. After correcting the new names for the objects, and fixing a syntax error in the run javascript example, That works, and I can fire a JavaScript alert from VBA.

To receive data from the example's mouse move event, I changed the line in the example from
s = bembHost.GetLastData()
s = bembHost.LastData
(no such method but there is the property) but when I print out s I just get "[object Object]". I can't work out why I am not receiving the string shown in the example.

As an experiment, I added code to the VBA bhCanvas_MouseMove() sub to fire a JavaScript alert to show the JavaScript mjvbData variable. It showed a correct value.

If it helps anyone, I have updated the .txt file of instructions to use the new object names, and with syntax errors corrected.
This post has been edited by Steve Waring: May 16 2019, 07:08 AM
Attached File(s)
Attached File  bembSetupInstrUpdated.txt ( 6.69K )Number of downloads: 5
Go to the top of the page
post May 16 2019, 08:29 AM

UtterAccess Editor
Posts: 9,982
Joined: 7-December 09
From: St Augustine, FL

Hi Steve,

It's been quite a while since I've played with this (and it's not set up all that well to begin with), so only a quick thought at the moment...

>> when I print out s I just get "[object Object]" <<

The [object Object] is what you would see in JS debugging indicating that rather than a string, it's an object. My off-the-top-of-my-head guess would be that maybe you could do a serialization from the object to a string that would (hopefully) return a JSON string to VBA, which can then be parsed to get the info you need.

Maybe take a look at JSON.stringify (https://stackoverflow.com/questions/8164802/serialize-javascript-object-into-json-string)


Go to the top of the page
post May 16 2019, 08:32 AM

UtterAccess VIP
Posts: 11,156
Joined: 6-December 03
From: Telegraph Hill


Thank you for sharing.

I have never used Jack's BrowseEmbed, but I'm a great admirer of all his stuff.

In the txt file you attached, should you also have adjusted the code in the sub in section 2) E) c) ? It still calls bembHost.GetLastData()

(I may be off the mark - I only gave it a quick scan!)





David Marten
Go to the top of the page
Steve Waring
post May 16 2019, 02:24 PM

Posts: 3
Joined: 16-May 19

I looked at the code in the working database that was provided in the download and saw that mjvbData has been replaced with the more meaningful bembData. So in the instructions, the final parameter to bembHost.AddEventHandler should be
"bembData = event.clientX + ', ' + event.clientY;"

I changed this, and the code now works fine.

I've changed the .txt file of instructions, including the line I forgot to change the first time (thanks cheekybuddha) and have uploaded it here.

I know your not doing much with this, but perhaps you could update the download zip. I think this code has so many uses besides charting, eg working with maps, it would be a shame to let it rot.

Many thanks,
Attached File(s)
Attached File  bembSetupInstrUpdated.txt ( 6.69K )Number of downloads: 3
Go to the top of the page
post May 17 2019, 05:19 AM

UtterAccess Editor
Posts: 9,982
Joined: 7-December 09
From: St Augustine, FL

Hi Steve, I have a copy of the updated file on my desktop and will reconcile it with the download site next time I'm cleaning off my desk.

If you happen to have a working demo of the bing maps, I'd be happy to include that (with credit to you) as well.

I've used this in a few other scenarios besides charting and agree it has a lot of potential, but is not the easiest to set up and use. At one point I had done another round of heavy refactoring to clean things up, but making the time to prep that for public use hasn't been at the top of the priority list, unfortunately. I'll talk to the mvp group and see if someone still active in Access wants to take over the project and breathe some life into it.


Go to the top of the page
Steve Waring
post May 17 2019, 06:25 AM

Posts: 3
Joined: 16-May 19

I'll send you a map example when I have it fully working. The bing maps API uses callbacks for things such as the map being dragged. I've done a test to see how to have one of these functions return data to VBA, and this works (baby steps)
<!DOCTYPE html>
<!-- saved from URL=(0022)http://www.dymeng.com/ -->
    <script type="text/javascript" src="jquery-1.11.1.min.js"></script>
var bembEvent = document.createEvent('CustomEvent');
var geo = new Object;
bembEvent.initCustomEvent('bemb', true, true, geo);
function clicked()
    geo.latitude = 30
    geo.longitude = 40
<body id="bembBody">
    <button type="button" id="testbutton" onclick="clicked()">test</button>

Private Sub bembHost_Initialized()
    bembHost.AddEventHandler _
        "#bembBody", _
        "bemb", _
        Me, _
        "buttonclicked", "bembData = event.detail.latitude"
End Sub

Public Sub buttonclicked()
    Debug.Print bembHost.LastData
End Sub

This post has been edited by Steve Waring: May 17 2019, 06:29 AM
Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    19th May 2019 - 07:45 PM