0
JavaScript 기본 Google지도 API를 사용하고 있는데 "geocoder.getlocations"를 사용하려고하면 "브라우저 비 호환성"예외가 반환되고지도가 언로드됩니다. 내 코드를 살펴보고 그 코드의 문제점을 알려주십시오.Google지도 API, Geocoder.GetLocations는 항상 "브라우저 호환되지 않음"을 반환합니다.
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.addControl(new GSmallMapControl());
map.addControl(new GNavLabelControl());
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
geocoder = new GClientGeocoder();
}
}
function showAddress(address) {
var zipcodex = 0;
if(geocoder)
{
geocoder.getLocations(address, getzip);
function getzip (response)
{
if (!response || response.Status.code != 200)
{
alert("Sorry, we were unable to geocode the first address");
}
else
{
if(response.Placemark[0].AddressDetails.Country.AdministrativeArea.
Locality.PostalCode.PostalCodeNumber)
{
zipcodex = response.Placemark[0].AddressDetails.Country.AdministrativeArea.
Locality.PostalCode.PostalCodeNumber;
}
}
}
}
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " not found");
} else {
map.setCenter(point, 13);
var marker = new GMarker(point);
map.addOverlay(marker);
if(zipcode)
{
marker.openInfoWindowHtml('Zipcode:'+zipcodex);
}
else
{
marker.openInfoWindowHtml(address);
}
}
}
);
}
}
나는이 추측 내 문제를 해결하지 못함 – Omayr
이 코드를 실행하는 브라우저 (버전)는 무엇입니까? –