' + addrHtml + '
'
});
var marker = new google.maps.Marker({
position: latLng,
title: name,
map: map
});
google.maps.event.addListener(marker, 'click', function() {
infoWindow.open(map, marker);
});
positions.push({location: latLng, id: id});
}
// request latitude and longitude by addr string and then set overlay for the branch
function setLocationByAddr(id, name, addrStr, addrHtml) {
geocoder.geocode( { address: addrStr, region: 'GB' }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
setLocation(id, name, results[0].geometry.location, addrHtml);
setPositions();
}
});
}
// make action for contact element
function makeContactAction(element, callback) {
var id = jQuery(element).parents(".bk-contact-location").find('input').val();
for (var i = 0; i George streetFailsworth
Manchester
Lancashire
M35 9BW
';
lat = 53.5129;
lng = -2.1568;
if (lat === null || lng === null) {
addrStr = 'George street, Failsworth, Manchester, Lancashire, M35 9BW';
setLocationByAddr(id, name, addrStr, addrHtml);
}
else {
setLocation(id, name, new google.maps.LatLng(lat, lng), addrHtml);
}
// ------------------------
setPositions();
// header action - zoom to the branch local
jQuery('.bk-contact-location-title').click(function() {
makeContactAction(this, setPosition);
});
// direction action - show direction from the supplied postcode to the branch location
jQuery('.bk-contact-direction-button').click(function() {
makeContactAction(this, function(location) {
var origin = jQuery.trim(jQuery('#bk-contact-direction-input').val());
if (!origin) {
alert('Please insert your postcode.');
return;
}
var request = {
origin: origin,
destination: location,
provideRouteAlternatives: false,
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.IMPERIAL,
region: 'GB'
};
if (directionsPanel) {
directionsService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(result);
}
else {
alert('Directions was not found.');
}
});
}
});
});
}
//]]>