-1
지도를 생성하는 데 Google지도 API를 사용하고 있습니다. 다음 코드를 사용하여 Google 크롬에서지도를 생성 할 수 있지만 Firefox에서는 작동하지 않습니다. 또한 콘솔에 해당 JS 오류가없고 해당 HTML이 파이어 폭스에서 생성되지 않습니다.Google지도가 파이어 폭스에 표시되지 않습니다
var map;
var marker;
var lat;
var lng;
var myLatlng;
var geocoder = new google.maps.Geocoder();
var infowindow = new google.maps.InfoWindow();
function initialize(){
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
myLatlng = new google.maps.LatLng(-23.69748,133.88362);
}
function showPosition(position) {
lat = position.coords.latitude;
lng = position.coords.longitude;
show_map(lat,lng);
}
function show_map(lat,lng){
var mapOptions = {
zoom: 18,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("myMap"), mapOptions);
map.setCenter(new google.maps.LatLng(lat,lng));
map.setZoom(8);
marker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(lat,lng),
draggable: true
});
geocoder.geocode({'latLng': new google.maps.LatLng(lat,lng) }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
infowindow.setContent(results[0].formatted_address);
infowindow.open(map, marker);
}
}
});
}
}
google.maps.event.addDomListener(window, 'load', initialize);
바이올린을 게시 할 수 있습니까? – xxxmatko
geocoder = new google.maps.Geocoder(); infowindow = new google.maps.InfoWindow(); - 그 줄을 initialize() 안에 넣으십시오. (선언문을 전역으로 유지할 수 있습니다). –
'navigator.geolocation'가 false이면,'myLatlng'을 소유로하여'show_map'을 호출하지 마십시오. – GramThanos