我完全沉浸在这里。 我使用Google Places API和Google Maps Javascript API v3来显示商家地图及其地址,电话号码等... 我在Webkit上开发了这个网站......然后我发现它在Firefox中不起作用...... 这是我的代码:
function initialize() {
var e = document.getElementById('place_reference')
if (e) {
var place_reference = document.getElementById('place_reference').innerText;
}
var request = {
reference: place_reference
};
service = new google.maps.places.PlacesService(document.getElementById('map_canvas'));
service.getDetails(request, callback);
function callback(place, status) {
console.log(status);
if (status == google.maps.places.PlacesServiceStatus.OK) {
document.getElementById('loading').style.display = 'none';
if (document.getElementById('place_address').innerText == '') {
document.getElementById('place_address').innerText = place.formatted_address;
}
if (document.getElementById('place_phone').innerText == '') {
document.getElementById('place_phone').innerText = place.international_phone_number;
}
if (document.getElementById('place_website').innerHTML == '') {
document.getElementById('place_website').innerHTML = '<a href="' + place.website + '"target="_blank">' + place.website + '</a>';
}
var place = place.geometry.location;
var marker;
var map;
var mapOptions = {
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDefaultUI: true,
scrollwheel: false,
center: place
};
map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);
marker = new google.maps.Marker({
map: map,
draggable: false,
animation: google.maps.Animation.DROP,
position: place
});
}
}
}
在Firefox上,状态返回INVALID_REQUEST而在其他浏览器上,它返回OK
我真的需要帮助来解决这个问题。您可以在以下地址查看网站:http://social-e.laclinique.biz/en/blog/shops/noel-eternel
答案 0 :(得分:3)
问题在于:
var place_reference = document.getElementById('place_reference').innerText;
FF不支持innerText,例如使用:
var place_reference = document.getElementById('place_reference').firstChild.nodeValue
(或)
var place_reference = document.getElementById('place_reference').innerHTML;