Click here to Skip to main content
15,887,821 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I want to develope apps in windows-8 using VisualStudio2012. When I copy the basic google map code which is given by google to VS2012 in javascript project. It keeps telling me there are some errors.
the code is here:
XML
<!DOCTYPE html>
 <html>
   <head>
     <title>Google Maps JavaScript API v3 Example: Map Simple</title>
     <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
     <meta charset="utf-8">
     <style>
       html, body, #map_canvas {
         margin: 0;
         padding: 0;
         height: 100%;
       }
     </style>
     <script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script>
       var map;
       function initialize() {
         var mapOptions = {
           zoom: 8,
           center: new google.maps.LatLng(-34.397, 150.644),
           mapTypeId: google.maps.MapTypeId.ROADMAP
         };
         map = new google.maps.Map(document.getElementById('map_canvas'),
             mapOptions);
       }

      google.maps.event.addDomListener(window, 'load', initialize);
     </script>
   </head>
   <body>
     <div id="map_canvas"></div>
   </body>
 </html>


the error is in this line:
google.maps.event.addDomListener(window, 'load', initialize);
the error is:
JavaScript runtime error: "google"undefined

so plz help me!
Posted

replace

C#
google.maps.event.addDomListener(window, 'load', initialize);


with following line of code..

C#
window.onload=initialize;
 
Share this answer
 
still we have getting same error.
JavaScript runtime error: "google"undefined

if any one give solution that's should be great.
 
Share this answer
 
try this

XML
var map;
       function initialize() {map = new google.maps.Map(document.getElementById(&#39;map&#39;), {
                zoom: intZoomLevel,
                center: new google.maps.LatLng(-34.397, 150.644),
                mapTypeId: google.maps.MapTypeId.ROADMAP
            });
 
Share this answer
 
v3
Hey there,

I just wrote a tutorial about using the Google Maps API with Windows 8, http://www.creepyed.com/2012/11/how-to-use-the-google-maps-api-on-windows-8/[^]. It has to do with how the script for Google Maps is called in the project and making sure you can get external content.

I was getting similar errors to you. I hope this helps!

Have a great day,
Ed
 
Share this answer
 
your source is wrong.
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?v=3&sensor=true"></script>
This the correct one.
It will help you.
 
Share this answer
 
v2
Comments
Anshu BM 15-Nov-12 2:41am    
Is it working? Let me know.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900