2010-12-15 2 views
0

을 사용하여 kml 파일을 Google 어스에 전달할 때 문제가 발생합니다. 도시를 보여주는 Google 어스 뷰를 작성하려고하지만 kml 파서 geoxml3을 사용하고 있습니다. 나는 원하는 위치를 처음 보여줄 때 자바 스크립트를 사용하여 Google지도를 작성했다. 이 잘 작동합니다. 나는 데이터베이스에서 주소와 kml 파일 참조를 제공하는 PHP 스크립트로부터 함수를 호출한다. 이 함수는 맵을 빌드하고, 모두 잘 돌아 갔을 때 'map_finished'플래그를 제어 플래그로 설정하고 빌드 Google 어스 뷰 함수를 호출합니다.geoxml3 클래스 및 ProjectedOverlay 클래스

// Get maps and earth from google 
google.load('maps', '2.s', {'other_params': 'sensor=true'}); 
google.load('earth', '1'); 

//Google Earth Initializer 
function initObjectEarth() { 
    // Check if Google Earth plugin is installed 
    if(gm_loaded) { 
    this.ge_plugin_installed = google.earth.isInstalled(); 

    if(this.ge_plugin_installed) { 
    google.earth.createInstance('inmap', geSuccessCallback, geFailureCallback); 
    ge_loaded = true; 
    } else { 
    alert('Your Browser has not yet installed the Google Earth plugin. 
      We recommend installing it to use all features!'); 
    return false; 
    } 
} 
} 

// Success handler 
function geSuccessCallback(object) { 
    this.ge = object; 
    this.ge.getWindow().setVisibility(true); 
    this.kmlParser = new geoXML3.parser(); 
} 

// Error handler 
function geFailureCallback(object) { 
    alert('Error: ' + object); 
} 

geoxml 파서는 ProjectedOverlay 클래스를 사용합니다. 두 라이브러리 모두 문서 헤드에로드됩니다. 파서가 instatiated되면 ProjectedOverlay 인스턴스를 요청합니다. 이 클래스는 빌드 기능에서 설정

var gm //for google map 
var ge //for google earth 

GM을 포함한 전 바르 선언 한 내 스크립트 파일에서 다음 문

ProjectedOverlay.prototype = new google.maps.OverlayView(); 

위해 불을 지르고에서

Error: **google.maps is undefined** 

오류가 발생합니다 구글지도.

이 문제를 해결하는 방법을 궁금합니다. 나는 웹상에서 발견 된 getProjection()을 시도했다.

ProjectedOverlay.prototype = new google.maps.OverlayView().prototype; 

성공하지 못했다. 이 주제는 나에게는 절대적으로 새로운 것이므로 OverlayView의 문서 또는 Google 검색에서 문제를 해결하는 방법을 찾을 수 없습니다.

무엇을 잊었 나 잘못 했습니까?

답변

0

geoXML3 생성자에 대한 호출이 잘못되었으므로 google.maps 객체를 매개 변수로 전달해야합니다 (따라서 ... "google.maps is undefined"오류).

this.kmlParser = new geoXML3.parser({map: gm}); // gm for google map