following is my code when user enters hospital name and city, he will be navigated to this page to show location on map. now i want to get user current location and draw the route between current location and destination. is there any way to integrate to geocoding and geolocation? please help me out. i'll be very thankful.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style>
html, body, #map-canvas
{
margin: 0;
padding: 0;
height: 700px;
width: 1350px;
}
</style>
<script src="http://maps.googleapis.com/maps/api/js??key=AIzaSyBcM1JmHJLyPH6m5xF0WzrqWJ9pSjCTQR4&sensor=false"></script>
<script>
var geocoder;
var map;
var marker;
function initialize() {
var mapOptions = {
zoom: 17,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
geocoder = new google.maps.Geocoder();
}
function geocode() {
var loc = '<%= Session["hname"] %>';
var city = '<%= Session["city"] %>';
geocoder.geocode({ address: loc+city }, function (results, status) {
if (status === google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var contentString = '<div id="content">' +
'Lat :' + results[0].geometry.location.lat() + '</br>lng :' + results[0].geometry.location.lng() +
'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
marker = new google.maps.Marker({
position: results[0].geometry.location,
map: map,
title: results[0].geometry.location.lat() + ' , ' + results[0].geometry.location.lng()
});
google.maps.event.addListener(marker, 'click', function () {
infowindow.open(map, marker);
);
}
});
return false;
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body onload="initialize();return geocode()" >
<form id="form2" runat="server">
<div id="map-canvas">
</div>
</form>
</body>
</html>