由于Internet Explorer,使用bing和google进行地理定位

嗨,我目前正在玩地理定位,除了IE之外,它一切都很好,因为它似乎不支持谷歌,并且想要使用Bing有没有人知道如何让IE友好的方向…它已经困扰了我好几天!

inheritance我的代码:

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: end, travelMode: google.maps.TravelMode.DRIVING }; directionsService.route(request, function (result, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(result); } }); } function fail() { fallback(); } 

快速搜索显示IE9应该支持地理定位,但它不如其他浏览器准确。 对于IE8及更早版本,您似乎必须使用“ polyfill ”,例如Webshims 。