Try this..
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>
<script type="text/javascript">
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var geocoder = new google.maps.Geocoder();
var infowindow = new google.maps.InfoWindow();
var latlang=new google.maps.LatLng(geoip_latitude(), geoip_longitude());
var start;var end;
function initialize()
{
directionsDisplay = new google.maps.DirectionsRenderer();
var myOptions = {
center: latlang,
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"), myOptions);
start=latlang;
geocoder.geocode({ 'latLng': latlang }, function (items, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setZoom(8);
var marker = new google.maps.Marker({
position: latlang ,
map: map
});
infowindow.setContent(items[1].formatted_address);
google.maps.event.addListener(marker, 'click', function () {
infowindow.open(map, this);
map.setZoom(8);
});
}
});
google.maps.event.addListener(map, 'click', function (event) {
geocoder.geocode({ 'latLng': event.latLng }, function (items, status) {
if (status == google.maps.GeocoderStatus.OK) {
$('#latitude').val(items[0].geometry.location.lat().toString().substr(0, 12));
$('#longitude').val(items[0].geometry.location.lng().toString().substr(0, 12));
marker = new google.maps.Marker({
position: event.latLng,
map: map
});
var ll=event.latLng;
infowindow.setContent(ll.toString());
infowindow.open(map, marker);
}
});
end=event.latLng;
directionsDisplay.setMap(map);
var request = {
origin:start,
destination:end,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(result);
}
});
start=event.latLng;
});
}
window.onload=initialize;
</script>
</head>
<body>
<div id="map" align="center" style="height: 420px; width:500px; top:0px; border: 1px solid black;"></div>
</body>
</html>