Andy points out the problem, you're recreating the map each time you click it. Try making your map
variable global so it's available to both functions, and get rid of the duplicate code between both functions. Something like:
var map, flightPath = new google.maps.Polyline();
function initialize()
{
var mapOptions =
{
zoom: 3,
center: new google.maps.LatLng(2.42249, 3.82618),
mapTypeId: google.maps.MapTypeId.TERRAIN
};
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
google.maps.event.addListener(map, 'click', function(event)
{
drawLine(event.latLng);
});
}
function drawLine(loc) {
var flightPlanCoordinates = [
new google.maps.LatLng(2.42249, 3.82618),
loc
];
flightPath.setMap(null);
flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
(updated to demonstrate clearing the polyline off the map each time you click)