I am using asp.net with C#. I embedded Google Maps in my application using JavaScript. I input latitude and longitude, and its shows the location on Google Maps. Now I want that it takes lat & lng from a database and shows the location.
Here's my code:
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC6v5-2uaq_wusHDktM9ILcqIrlPtnZgEk&sensor=false">
</script>
<script type="text/javascript">
function initialize() {
var lat = document.getElementById('txtlat').value;
var lon = document.getElementById('txtlon').value;
var myLatlng = new google.maps.LatLng(lat, lon)
var mapOptions = {
center: myLatlng,
zoom: 18,
mapTypeId: google.maps.MapTypeId.ROADMAP,
marker: true
};
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng
});
marker.setMap(map);
}
</script>
</head>
<body >
<table>
<tr>
<td class="style3">Enter Latitude:</td>
<td><input type="text" id="txtlat" value="" onclick="return txtlat_onclick()" /> </td>
</tr>
<tr>
<td class="style3">Enter Longitude:</td>
<td><input type="text" id="txtlon" value="" onclick="return txtlon_onclick()" /> </td>
</tr>
<tr>
<td> </td>
<td><input type="button" value="Submit" onclick="javascript:initialize()" /> </td>
</tr>
</table>
<div id="map_canvas" style="width: 535px; height: 347px"></div>
</body>
</html>