I am trying to display a Google map on an ASP.net web form page.
Javascript is as follows:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=xxxxx&sensor=false"> </script> <script type="text/javascript"> var map; function initialize() { var mapOptions = { zoom: 8, center: new google.maps.LatLng(-34.397, 150.644), mapTypeId: google.maps.MapTypeId.ROADMAP }; var mapcv = document.getElementById('map-canvas'); map = new google.maps.Map(mapcv, mapOptions); } google.maps.event.addDomListener(window, 'load', initialize); </script>
I used the following HTML and it does not work if I put the div tag in the form tag.
<form id="form1" runat="server"> <div id="map-canvas" ></div> </form>
But if I move the div tag outside the form tag as below, it works
<div id="map-canvas" ></div> <form id="form1" runat="server"> </form>
I want to put the div tag inside the form. Could you help me, how can I do this? Thanks.
source share