Google지도에서 일부 POI를 클릭하면지도 엔진이 시스템 기본 정보 창을 엽니 다. 어떻게 그 창에 대한 참조를 얻습니까? 다음에지도를 클릭하면 닫을 수 있습니다.시스템 정보 창을 어떻게 참조합니까?
0
A
답변
2
전에 몇 가지 비슷한 질문이 계속있다 :
- How to get a click event when a user clicks a (business) place on the map
- 에 대한 참조를 얻을 수있는 정보창 - 프로토 타입의 메소드를 오버라이드 (override) 할 수있다 접근 방식은, 코드를 적용
//run this after loading the maps-api
(function(){
var fx = google.maps.InfoWindow.prototype.setContent;
//override the built-in setContent-method
google.maps.InfoWindow.prototype.setContent = function() {
//this property isn't documented, but as it seems
//it's only defined for InfoWindows opened on POI's
if (this.logAsInternal) {
google.maps.event.addListenerOnce(this, 'map_changed',function() {
var map = this.getMap(),that=this;
//attach the click-handler when the infowindow opens
if (map) {
google.maps.event.addListenerOnce(map, 'click', function(){that.close();});
}
});
}
//call the original setContent-method
fx.apply(this, arguments);
};})();
3
Google지도 API 문제 추적기에서 추적되는 문제 # 4797이며 최근에 수정되어 버전 3.26에서 사용할 수 있습니다.
버전 3.26부터 Map 객체의 "click"이벤트를 수신해야합니다. 사용자가 POI를 클릭하면 IconMouseEvent가 발생합니다. 이 클래스는 Regular MouseEvent를 확장하며 placeId라는 속성을 포함합니다. 따라서 이벤트 객체가 placeId를 정의했는지 확인할 수 있습니다. placeId 필드에는 물론 장소 ID가 포함되어 있으며, 클릭 한 아이콘에 대한 자세한 정보를 얻기 위해 Places API와 함께 사용할 수 있습니다. 지도 "클릭"이벤트 핸들러는 다음과 같이한다 한마디로 http://jsbin.com/parapex/10/edit?html,output
:
// This is the click event handler
var handleClick = function(event) {
// If the event has a placeId, use it.
if (event.placeId) {
// Calling e.stop() on the event prevents the default info window
// from showing.
// If you call stop here when there is no placeId you will prevent
// some other map click event handlers from receiving the event.
event.stop();
// do something with event.placeId here. Like calling places service
}
};
관련 문제
- 1. 파일 시스템 정보 - 어떻게 쿼리합니까?
- 2. 정보 시스템
- 3. 패키지 코드가있는 VS 코드의 시스템 어셈블리를 어떻게 참조합니까?
- 4. PHP 함수는 어떻게 참조합니까?
- 5. dylib를 어떻게 참조합니까?
- 6. backbone.js보기에서 모델을 어떻게 참조합니까?
- 7. AppDelegate.swift의 메소드를 어떻게 참조합니까?
- 8. 함수의 변수를 어떻게 참조합니까?
- 9. 어떻게 다차원 배열을 참조합니까?
- 10. 이 변수는 어떻게 참조합니까?
- 11. PHP에서 클래스를 어떻게 참조합니까?
- 12. WebComponent 인스턴스를 어떻게 참조합니까?
- 13. PHP는 현재 문서를 어떻게 참조합니까?
- 14. 프로그래밍 방식으로 열린 시스템 정보
- 15. Visual Basic 시스템 정보
- 16. 새 정보 창이 열리면 정보 창을 닫으시겠습니까?
- 17. 하위 클래스의보기 컨트롤러를 어떻게 참조합니까?
- 18. 다른 파일의 변수를 어떻게 참조합니까?
- 19. boost :: variant 저장소는 어떻게 참조합니까?
- 20. clojurescript에서 javascript의이 키워드를 어떻게 참조합니까?
- 21. 플라스크에서 여러 모델을 어떻게 참조합니까?
- 22. 반짝이는 슬라이더의 값을 어떻게 참조합니까?
- 23. RailsTutorial SessionsHelper는 UsersContoller가 어떻게 참조합니까?
- 24. 종속성에서 Maven 프로파일을 어떻게 참조합니까?
- 25. 레지스트리에 저장된 경로를 어떻게 참조합니까?
- 26. 매트릭스의 인접 요소를 어떻게 참조합니까?
- 27. 헤더 파일의 typedef는 어떻게 참조합니까?
- 28. 모델에서 이러한 열을 어떻게 참조합니까?
- 29. Storyboards를 사용하여 UISearchController를 어떻게 참조합니까?
- 30. 루아에서 인스턴스 변수를 어떻게 참조합니까?
당신은 사람들을 참조 할 수 없습니다
나는 작은 데모를 준비했다. – geocodezip좋은 의견이없는 투표와 가까운 투표. – Kolyunya
가능한 중복 [Google지도 API의 흥미로운 장소의 기본 정보 창과 작업] (http://stackoverflow.com/questions/21202034/work-with-native-infowindows-of-interesting-places-in-google-maps- api/21884991 # 21884991) – geocodezip