Welcome to the Frontpage
Snap To Road - Google Maps API
var directionDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer();
var myOptions = {
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: new google.maps.LatLng(55.40586, 10.38306)
}
document.getElementById('map_canvas').style.height = screen.availHeight;
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
directionsDisplay.setMap(map);
google.maps.event.addListener(map, 'click', function (e) {
var request = {
origin: e.latLng,
destination: e.latLng,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function (response, status) {
if (status == google.maps.DirectionsStatus.OK) {
var route = response.routes[0];
var marker = new google.maps.Marker({
position: route.legs[0].end_location,
map: map,
title: route.legs[0].end_address
});
Alert("Lat/Lng: " + route.legs[0].end_location + "\nAddress: " + route.legs[0].end_address )
}
});
});
}
Notepad++Name: Notepad++ Info: This is a great replacement for Windows Notepad.. it offers alot of code lang support (Php,Java,Asp and alot more) |





