Google Maps not working

Last post 07-26-2009 3:47 PM by tmargot. 3 replies.

Sort Posts:

  • Google Maps not working

    06-29-2009, 9:57 AM
    • Member
      3 point Member
    • tmargot
    • Member since 03-09-2009, 6:10 PM
    • Posts 21

     Google maps is not working and for the life of me cannot figure out why. It works in a straight HTML file. At first I thought it may be the ASP.NET Menu Control conflicting, but now I have created this basic file and it still does not work. I call the Google Map code from the body onload, but then decided for testing to do it simple as below. Could someone please help?

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="map_no_master.aspx.cs" Inherits="AccountsRapport.map_no_master" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <div id="map_canvas" style="width: 300; height: 300;"></div>
      <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
      <script type="text/javascript">
      	var myLatlng = new google.maps.LatLng(51.372149, -0.457936);
      	var myOptions = {
      		zoom: 15,
      		center: myLatlng,
      		mapTypeId: google.maps.MapTypeId.ROADMAP
      	}
      	var map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
    
    
      	var marker = new google.maps.Marker({
      		position: myLatlng,
      		map: map,
      		title: 'Accounts Rapport'
      	});   
    </script>
    
        </div>
        </form>
    </body>
    </html>
    


     

    Filed under:
  • Re: Google Maps not working

    06-30-2009, 2:53 AM

    Hi,

    nothing wrong with the code just put :

    <div id="map_canvas" style="width: 300px; height: 300px;"></div> and the map will come nicely and you can smile.

    Always "Mark as Answer" the Post That Solves the problem.Because It helps others to find the solution.
    Mohammad Hussain
    http://mohdhussain.blogspot.com/
  • Re: Google Maps not working

    06-30-2009, 4:50 AM
    • Member
      3 point Member
    • tmargot
    • Member since 03-09-2009, 6:10 PM
    • Posts 21

    mohd786hussain:

    Hi,

    nothing wrong with the code just put :

    <div id="map_canvas" style="width: 300px; height: 300px;"></div> and the map will come nicely and you can smile.

     

    Thanks very much for the reply. I still have the problem even after placing the div (I had multiple versions for testing and forgot the div on that specific test.

    I found my problem lies in the doctype, if I remove it, everything works fine. I have tried different doctypes but still have the same problem.

  • Re: Google Maps not working

    07-26-2009, 3:47 PM
    Answer
    • Member
      3 point Member
    • tmargot
    • Member since 03-09-2009, 6:10 PM
    • Posts 21

    After looking at many solution on registering google's javascript with ASP.NET I cheated and put the map into a standard HTML file and placed an iFrame on the asp.net page with the map.html file loaded into it.

Page 1 of 1 (4 items)