こんにちは、 http: //harpers.everythingcreative.co.uk/contactにアクセスするとわかるように、私のGoogleマップでGoogle infoWindowを無効にしますか?情報ウィンドウが奇妙に見え、間違ったアドレスが表示されます。
// ---------- Geolocation ----------
function fallback() {
var myOptions = {
center: new google.maps.LatLng(51.43255949795703, -0.461750328540802),
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("Map_Canvas"),
myOptions);
var markerPos = new google.maps.LatLng(51.43255949795703, -0.461750328540802);
var marker = new google.maps.Marker({
position: markerPos,
map: map,
title: "The Harpers Hairdressing"
});
}
function initGeolocation()
{
if(navigator.geolocation)
{
// Call getCurrentPosition with success and failure callbacks
navigator.geolocation.getCurrentPosition( success, fail );
}
else
{
fallback()
}
}
var directionDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
function success(position) {
directionsDisplay = new google.maps.DirectionsRenderer();
coords = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
var myOptions = {
zoom:12,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: coords
}
map = new google.maps.Map(document.getElementById("Map_Canvas"),
myOptions);
directionsDisplay.setMap(map);
calcRoute();
}
function calcRoute() {
var start = coords;
var end = new google.maps.LatLng(51.43255949795703, -0.461750328540802);
var request = {
origin:start,
destination: "3 Fir Tree Place, Church Road, Ashford, Middlesex, TW15 2PH",
travelMode: google.maps.TravelMode.DRIVING,
};
directionsService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(result);
}
});
}
function fail()
{
fallback();
}
ご覧のとおり、フォールバックはシンプルなマーカーであり、情報ウィンドウは表示されませんが、ルート案内は表示されます。