我正在做一个非常简单的地理位置查询,在Firefox,Chrome,Safari,Android和Apple设备上运行良好。在IE浏览器中,虽然Microsoft位置服务将我的位置放在500英里以外。这是脚本。
<button id="getlocal" onclick="getLocation()">Check by my Current Location</button>
<p id="demo"></p>
<script>
var x = document.getElementById("demo");
$("#getlocal").click(function(){
$("#getlocal").hide();
});
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
var json = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + position.coords.latitude +
", " + position.coords.longitude;
$.getJSON(json, function (json) {
var address = json.results[0].address_components[4].long_name;
var address2 = json.results[0].address_components[3].long_name;
if(address == "LaSalle County" || address == "Grundy County" || address == "Livingston County" || address == "Marshall County" || address == "Putnam County" || address == "Wood ford County" || address == "McLean County" || address == "Bureau County" ){
x.innerHTML = "<p class=\"green\"><i class=\"material-icons\">thumb_up</i> Based on your current location in " + address + ", <b>you are eligible for membership</b>. Please review all qualifications above to determine if you fully qualify.</p>";
}else if(address2 == "LaSalle County" || address2 == "Grundy County" || address2 == "Livingston County" || address2 == "Marshall County" || address2 == "Putnam County" || address2 == "Woodford County" || address2 == "McLean County" || address2 == "Bureau County" ){
x.innerHTML = "<p class=\"green\"><i class=\"material-icons\">thumb_up</i> Based on your current location in " + address2 + ", <b>you are eligible for membership</b>. Please review all qualifications above to determine if you fully qualify.</p>";
}else{
x.innerHTML = "<p class=\"redalert\">Sorry you are not eligible at this time, based on your current location in <b>" + address2 + ", " + address +"</b>. You may still qualify though, please read above to learn more. If this location is wrong please call us at 815-673-5577 to determine your membership status.</p>";
}
});
}
</script>
有没有办法强制IE使用Google位置服务?还是我坚持IE想要发送给我的东西?