Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 131
  • Last Modified:

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: 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
João serras-pereira
Asked:
João serras-pereira
  • 8
  • 5
1 Solution
 
leakim971PluritechnicianCommented:
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
 
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...
0
 
leakim971PluritechnicianCommented:
removing the pushpin by commenting it

you mean the button line 37, right ? ;^^
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
João serras-pereiraAuthor Commented:
YES! (I am so thrilled with your help that I am typing the wrong words...
1
 
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:

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
 
leakim971PluritechnicianCommented:
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
 
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...
0
 
leakim971PluritechnicianCommented:
just try again
0
 
João serras-pereiraAuthor Commented:
sure
0
 
João serras-pereiraAuthor Commented:
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
 
leakim971PluritechnicianCommented:
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
 
João serras-pereiraAuthor Commented:
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
 
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
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now