Solved

javascript error when invoking bingmaps

Posted on 2016-11-26
13
16 Views
Last Modified: 2016-11-26
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: http://www.bing.com/api/maps/sdk/mapcontrol/isdk#displayInfoboxOnClickPushpin+JS
is:

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 });
infobox.setMap(map);
Microsoft.Maps.Events.addHandler(pushpin, 'click', function () {
    infobox.setOptions({ visible: true });
});
map.entities.push(pushpin);

Open in new window

map.html
0
Comment
Question by:jirdeaid
  • 8
  • 5
13 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
Comment Utility
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>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>pushpinLabelsHTML</title>
		<script type="text/javascript" src="http://www.bing.com/api/maps/mapcontrol?branch=release&callback=loadMapScenario" 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}); 
				map.setView({center:center});  	
				addInfobox(strTitulo, strSubTitulo);
				map.entities.push(pin);	

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

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

Open in new window

0
 

Author Comment

by:jirdeaid
Comment Utility
:)

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...
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
removing the pushpin by commenting it

you mean the button line 37, right ? ;^^
0
 

Author Comment

by:jirdeaid
Comment Utility
YES! (I am so thrilled with your help that I am typing the wrong words...
1
 

Author Comment

by:jirdeaid
Comment Utility
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:

letra:A
tit:PDA.35F015
subtit:Furo
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
        DoEvents
    Loop
    Debug.Print Now()
    InvokeJavaScript "addPushpin(" + strLatGPS + ", " + strLgtGPS + " ,'" + strLetraPushPin + "','" + strTitulo + "' ,'" + strSubTitulo + "');"
    InvokeJavaScript "addInfoBox(" + strInfoTitulo + ", " + strInfoDetalhe + " );"
map.html
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
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
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:jirdeaid
Comment Utility
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...
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
just try again
0
 

Author Comment

by:jirdeaid
Comment Utility
sure
0
 

Author Comment

by:jirdeaid
Comment Utility
it really works

Screen-Shot-2016-11-26-at-21.43.04.png

however, in the code you sent me I do not find how you do invoke the add infobox with its specific parameters (title/detail)
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
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
0
 

Author Comment

by:jirdeaid
Comment Utility
no.. behaviour is perfect.

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

Screen-Shot-2016-11-26-at-22.07.40.png
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...
0
 

Author Closing Comment

by:jirdeaid
Comment Utility
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
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 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

11 Experts available now in Live!

Get 1:1 Help Now