function initYWPDirectionMap() {
ywpDirectionsDisplay = new google.maps.DirectionsRenderer({
draggable: false,
suppressInfoWindow: true,
suppressMarkers: true
});
var ywpDirOptions = {
zoom: 5,
center: new google.maps.LatLng(65.00,-135.00),
mapTypeId: google.maps.MapTypeId.HYBRID,
mapTypeControl: true,
streetViewControl: false,
minZoom: 4
};
var start;
if ( geoLocation && currentLatitude && currentLongitude ) {
start = new google.maps.LatLng(currentLatitude, currentLongitude);
}
else {
start = new google.maps.LatLng(60.7333, -135.094);
}
var end = new google.maps.LatLng(60.87116, -135.3384);
var request = {
origin:start,
destination:end,
travelMode: google.maps.TravelMode.DRIVING
};
ywpDirectionsService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionResult = result;
ywpDirectionsDisplay.setDirections(result);
}
else {
//TODO: handle exception
}
});
// create custom markers
var markerValues = [{iconUrl: '../resources/images/mapicons/youAreHere.png',
title: 'You are here, more or less!'},
{iconUrl: '../resources/images/mapicons/ywp.png',
title: 'Yukon Wildlife Preserve'}
];
for ( var i = 0; i < markerValues.length; i++ ) {
var icon = new google.maps.MarkerImage(markerValues[i].iconUrl,
new google.maps.Size(32.0, 37.0),
new google.maps.Point(0, 0),
new google.maps.Point(16.0, 18.0));
var shadow = new google.maps.MarkerImage('../resources/images/mapicons/shadow.png',
new google.maps.Size(51.0, 37.0),
new google.maps.Point(0, 0),
new google.maps.Point(16.0, 18.0));
var marker = new google.maps.Marker({
position: start,
map: ywpDirectionsMap,
icon: icon,
shadow: shadow,
title: markerValues[i].title
});
addDirectionsInfoWindow(marker);
}
ywpDirectionsMap = new google.maps.Map(document.getElementById('dir-gmap'), ywpDirOptions);
ywpDirectionsDisplay.setMap(ywpDirectionsMap);
}
function addDirectionsInfoWindow(marker) {
google.maps.event.addListener(marker, 'click', function() {
directionsInfoWindow.setContent(marker.title);
directionsInfoWindow.open(ywpDirectionsMap, marker);
});
}
--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.