Reputation: 79
I'm totally floored here. I used the Google Places API along with Google Maps Javascript API v3 to display a map of commerces with its address, phone number etc... I developed the website on Webkit... Then I found out that it just didn't work in Firefox... Here's my code:
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
});
}
}
}
On Firefox, the status return INVALID_REQUEST while on other browser, it return OK
I really need help to figure this out. You can check out the website at this address: http://social-e.laclinique.biz/en/blog/shops/noel-eternel
Upvotes: 0
Views: 1201
Reputation: 117314
The issue is here:
var place_reference = document.getElementById('place_reference').innerText;
innerText is not supported by FF, use e.g.:
var place_reference = document.getElementById('place_reference').firstChild.nodeValue
(or)
var place_reference = document.getElementById('place_reference').innerHTML;
Upvotes: 4