javascript error when invoking bingmaps

I had this question after viewing javascript (?) could not complete the operation  due to error 80020101.

I have a working function which I had to upgrade to include additional functionality. Now  I am experiencing a systematic 800xxx error as I am invoking it. The source html page it attached and original code, sourced  from microsoft:

var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
    credentials: 'Your Bing Maps Key',
    center: new Microsoft.Maps.Location(47.60357, -122.32945)
var center = map.getCenter();
var pushpin = new Microsoft.Maps.Pushpin(map.getCenter(), null);
var infobox = new Microsoft.Maps.Infobox(center, { title: 'Map Center',
    description: 'Seattle', visible: false });
Microsoft.Maps.Events.addHandler(pushpin, 'click', function () {
    infobox.setOptions({ visible: true });

Open in new window

João serras-pereiraAsked:
Who is Participating?
leakim971Connect With a Mentor PluritechnicianCommented:
I added a button on this page to help you test without MS Access.
Open the page in your browser and click on the button to test it before trying with MS Access.
<!DOCTYPE html>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<script type="text/javascript" src="" async defer></script>
		<script type="text/javascript">
			var map;

			function loadMapScenario() {
				var options = { credentials: "AtmgIDsskKTlLBNr_LUOcdlK9ZFu3ZPBCdN_o5OSIh01ShsuR4mmzZAuD3PvGyaQ", zoom:18 };
				map = new Microsoft.Maps.Map(document.getElementById("myMap"), options);

			function addPushpin(strLatGPS, strLgtGPS, strLetraPushPin, strTitulo, strSubTitulo) {

				var center = new Microsoft.Maps.Location(strLatGPS*1, strLgtGPS*1);
				var pin = new Microsoft.Maps.Pushpin(center, {text: strLetraPushPin, title: strTitulo, subTitle: strSubTitulo}); 
				addInfobox(strTitulo, strSubTitulo);

				function addInfobox(infoTitle, infoContent) {
					var infobox = new Microsoft.Maps.Infobox(center, { title: infoTitle, description: infoContent, visible: false });
					Microsoft.Maps.Events.addHandler(pin, 'click', function () {
						infobox.setOptions({ visible: true });

		<button id="button1" onclick="addPushpin(11,-15,'X','PDA.36G017','Fonte');">PUSH PIN</button>
		<div id="myMap" style="width: 100vw; height: 100vh;"></div>

Open in new window

João serras-pereiraAuthor Commented:

the pushpin is there and the add on text as well....

I'll move it to the main db now, removing the pushpin by commenting it and will come back in a minute...
removing the pushpin by commenting it

you mean the button line 37, right ? ;^^
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

João serras-pereiraAuthor Commented:
YES! (I am so thrilled with your help that I am typing the wrong words...
João serras-pereiraAuthor Commented:
strange ---

(I deleted the push button line as the button kept showing in spite of the double slash at the beginning of the line (I think that's the way to comment)

but then restarted the 800xxx problem

after telling OK it continued and correctly showed the pushpin. clicking on the pin it shows the infobox but its content is the same as the title and subtitle of the pin.

my data is:

InfoTit:teste título
Infodetail:teste detalhe mas com mais palavras

and the code to invoke is:

    strLetraPushPin = Forms![_commonVariables]![letraPushPin]
    strTitulo = Forms![_commonVariables]![titulo]
    strSubTitulo = Forms![_commonVariables]![subtitulo]
    strInfoTitulo = "teste título"
    strInfoDetalhe = "teste detalhe mas com mais palavras"
    Debug.Print "lat:" & strLatGPS
    Debug.Print "lon:" & strLgtGPS
    Debug.Print "letra:" & strLetraPushPin
    Debug.Print "tit:" & strTitulo
    Debug.Print "subtit:" & strSubTitulo
    Debug.Print "InfoTit:" & strInfoTitulo
    Debug.Print "Infodetail:" & strInfoDetalhe
    'mostrar o pushpin
    Debug.Print strLatGPS & " / " & strLgtGPS & "/" & strLetraPushPin & "/" & strTitulo & "/" & strSubTitulo
    Debug.Print Now()
    Do While m_WebBrowser.ReadyState <> READYSTATE_COMPLETE
    Debug.Print Now()
    InvokeJavaScript "addPushpin(" + strLatGPS + ", " + strLgtGPS + " ,'" + strLetraPushPin + "','" + strTitulo + "' ,'" + strSubTitulo + "');"
    InvokeJavaScript "addInfoBox(" + strInfoTitulo + ", " + strInfoDetalhe + " );"
you was on a previous "test", that happen to me a lot
just be sure to close windows , stop debug/execution before  trying again.
you currently have nothing to change on Access and you test it on your browser
João serras-pereiraAuthor Commented:
ah. ok
But on the normal browser it was working PERFECTLY as I told you.

when I pressed the push it was WORKING!

only then I deleted the button, moved to access and invoked from it...
just try again
João serras-pereiraAuthor Commented:
João serras-pereiraAuthor Commented:
it really works


however, in the code you sent me I do not find how you do invoke the add infobox with its specific parameters (title/detail)
this addInfobox(strTitulo, strSubTitulo);
call this function addInfobox(infoTitle, infoContent) {
using the same strTitulo, strSubTitulo as the pin
by default the infobox is not visible be cause this part : , visible: false });
when we click on the pin because of this : Microsoft.Maps.Events.addHandler(pin, 'click',
we show the infoxbox with this : infobox.setOptions({ visible: true });

if you want to set the infobox visible and not on click on the pin, the code need to be update
João serras-pereiraAuthor Commented:
no.. behaviour is perfect.

So, I need to include 2 additional parameters in the addpushpin. now I understand better.

I have edited the map.html and sending in to you and now I think I can go back to the access code to test.

but I need to shutdown for some hours now as electricity is going to be cut off...
João serras-pereiraAuthor Commented:
Thanks a LOT! it is working perfectly inside ms/access - I now need to improve my own title/subtitle generation algorithm (for the infobox as well) and prepare for the next challenge, for which I will ask a related question, hopefully in a few hours.

BTW following your suggestion, I could ftp the map.html to my site. but now I wonder what would be the url to use, so I am putting a related question on this
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.