yaswant singh
yaswant singh

Reputation: 349

Bing Maps V8 -Uncaught ReferenceError: Microsoft is not defined

I am using bing map in my application for searching. Bing map V8 control.

I have used this CDN

<script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=api_key' async defer></script>

after that when I am trying to use Microsoft.Maps. It is saying:

Uncaught ReferenceError: Microsoft is not defined

new Microsoft.Maps.Color(100,100,0,100); 

Any one have idea about this?

Upvotes: 4

Views: 7554

Answers (2)

SHIVANG YADAV
SHIVANG YADAV

Reputation: 21

I encountered a similar error while using bing maps js sdk. All you have to do is to add 'windows.' before you write: Microsoft.Maps.Color(100,100,0,100);

So now the new code is :

new window.Microsoft.Maps.Color(100,100,0,100);

Upvotes: 2

Rohan Kumar
Rohan Kumar

Reputation: 40639

Don't use async while loading Bing API,

<script src='http://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=api_key'
          type='text/javascript' ></script>

And if you are using jQuery then add $.ready() to use maps like

<script>
   $(function(){
       var color = new Microsoft.Maps.Color(100,100,0,100); 
       ....
   });    
</script>

Upvotes: 5

Related Questions