지도에 클러스터 된 마커 세트가 있습니다. 다른 마커 집합이 개별적으로 표시되며 클러스터 위에 표시해야합니다. 클러스터 옵션 객체에서 zIndex를 설정하려고했지만 두 번째 세트의 마커보다 낮지 만 아무 소용이 없습니다. 이것에 대해 어떻게 생각하세요?Google지도 : markerclusterer 위의 마커 렌더링
답변
내가 아는 한이 일은 할 수 없습니다. 클러스터는 마커 이미지보다 높은 창에 있습니다.
https://developers.google.com/maps/documentation/javascript/reference#MapPanes
당신은 절대적으로 정확합니다. –
그것은 수행 할 수 있습니다,하지만 당신은 거기까지 꽤 울퉁불퉁 방법 ... 릭이 말했듯이, 문제는 MarkerClusterer이 높은 창으로에 미치는 클러스터 아이콘과 함께 자신의 있도록 OverlayView를 추가하는 것입니다 정규 마커. 클러스터 위에 마커를 추가하는 유일한 방법은 자체 무기로 클러스터러를 물리 치고 고유 한 OverlayView를 추가하고 더 높은 창에 마커 아이콘 마크 업을 추가하는 것입니다 (팬 here에 대해 읽음). 나는 그것을 정말로 좋아하지 않는다. 그러나 그것이 내가 발견했던 유일한 길이다.
이렇게하려면 google.maps.OverlayView (reference)를 구현하는 맞춤 오버레이를 만들어야합니다. 좋은 예는 here입니다 (설명과 함께 약간의 코드를 사용함).
// build custom overlay class which implements google.maps.OverlayView
function CustomOverlay(map, latlon, icon, title) {
this.latlon_ = latlon;
this.icon_ = icon;
this.title_ = title;
this.markerLayer = jQuery('<div />').addClass('overlay');
this.setMap(map);
};
CustomOverlay.prototype = new google.maps.OverlayView;
CustomOverlay.prototype.onAdd = function() {
var $pane = jQuery(this.getPanes().floatPane); // Pane 6, one higher than the marker clusterer
$pane.append(this.markerLayer);
};
CustomOverlay.prototype.onRemove = function(){
this.markerLayer.remove();
};
CustomOverlay.prototype.draw = function() {
var projection = this.getProjection();
var fragment = document.createDocumentFragment();
this.markerLayer.empty(); // Empty any previous rendered markers
var location = projection.fromLatLngToDivPixel(this.latlon_);
var $point = jQuery('<div class="map-point" title="'+this.title_+'" style="'
+'width:32px; height:32px; '
+'left:'+location.x+'px; top:'+location.y+'px; '
+'position:absolute; cursor:pointer; '
+'">'
+'<img src="'+this.icon_+'" style="position: absolute; top: -16px; left: -16px" />'
+'</div>');
fragment.appendChild($point.get(0));
this.markerLayer.append(fragment);
};
이 오버레이지도, 위도 경도 객체와 아이콘의 URL을 가져옵니다
여기에 거친 CustomOverlay 프로토 타입입니다. 좋은 점은 자신 만의 HTML을 레이어에 작성할 수 있다는 점입니다. 나쁜 점은지도 API가 제공하는 모든 물건 (마커 이미지 앵커 처리와 같은)을 직접 처리해야한다는 것입니다. 이 예제는 앵커가 이미지 중간에있는 32x32 픽셀 이미지에서만 잘 작동하므로 여전히 매우 까다 롭습니다.
는 다음과 같이 인스턴스화의 CustomOverlay를 사용하려면// your map center/marker LatLng
var myLatlng = new google.maps.LatLng(24.247471, 89.920990);
// instantiate map
var map = new google.maps.Map(
document.getElementById("map-canvas"),
{zoom: 4, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP}
);
// create the clusterer, but of course with markers
//var markerClusterer = new MarkerClusterer(map, []);
// add custom overlay to map
var customCustomOverlay = new CustomOverlay(map, myLatlng, 'http://www.foo.bar/icon.png');
나는이 당신을 위해 작동 바랍니다.
동일한 문제가 있었지만 새 오버레이를 처리하고 싶지 않았습니다.
특정 오버레이를 만들지 않고도 오버레이의 상위 컨테이너 z- 색인을 전환 할 수 있습니다.
이
는 다음과 같은 기능을 사용하여 달성 할 수 있습니다_changeOverlayOrder = function(map) {
var panes = map.getPanes();
var markerOverlayDiv = panes.overlayImage.parentNode;
var clusterOverlayDiv = panes.overlayMouseTarget.parentNode;
// Make the clusters clickable.
if(!markerOverlayDiv.style.pointerEvents) {
markerOverlayDiv.style.cssText += ";pointer-events: none;";
}
// Switch z-indexes
if(markerOverlayDiv.style.zIndex < clusterOverlayDiv.style.zIndex) {
var tmp = markerOverlayDiv.style.zIndex;
markerOverlayDiv.style.zIndex = clusterOverlayDiv.style.zIndex;
clusterOverlayDiv.style.zIndex = tmp;
}
};
는 도움이되기를 바랍니다.
this.getPanes()에 "this"가 무엇입니까? – marcovtwout
@ mouwah의 답변은 거의 정확하지만 맵 객체에는'getPanes()'메소드가 없습니다. 'getPanes()'메서드를 사용하고'overlayMouseTarget' 창의'zIndex'를 변경하려면 커스텀'OverlayView()'클래스를 정의해야합니다. –
이 코드는 지금까지 완벽하게 작동했지만 ** 지금은 Google이 무언가를 변경하고 갑자기 작동을 멈췄습니다! ** – TMS
- 1. Google지도 MarkerClusterer v3과 뷰포트 마커 관리
- 2. Google지도 MarkerClusterer v3 마커 클러스터 반환
- 3. Google지도 MarkerClusterer
- 4. Google지도 마커 클러스터
- 5. Google지도 마커 클러스터링 - markerclusterPlus
- 6. 마커 클러스터 러 Google지도
- 7. Google지도 마커 클러스터러가 작동하지 않습니다.
- 8. MarkerWithLabel Google지도 맞춤 마커
- 9. Google지도 클릭 마커 기능 문제
- 10. Google지도 V3 : 거리에서만 마커?
- 11. Google지도 - 다각형을 포함하는 마커
- 12. Google지도 IE7 마커 setIcon
- 13. Google지도 - 다중 마커
- 14. Google지도 마커 커서
- 15. Google지도 연결 마커
- 16. Google지도 마커 위치로 확대
- 17. Google지도 Ajax 새로운 마커
- 18. Google지도 - 마커 클릭시 창로드
- 19. Google지도 앱의 맞춤 마커
- 20. Fancybox에서 Google지도 마커 시작
- 21. Google지도 V3는 마커
- 22. 특정 Google지도 마커 참조하기
- 23. Google지도 관련 맞춤 마커
- 24. Google지도 최대 마커
- 25. Google지도 마커 업데이트
- 26. Google지도 v3 배열 마커
- 27. Google지도 API 여러 마커
- 28. Google지도 마커 중복 방지
- 29. PHP 및 Google지도 마커
- 30. Markerclusterer Google지도 API V3 - Bug : 확대/축소 레벨 2에서 부분적으로 클러스터되지 않은 마커
비슷한 질문 : http://stackoverflow.com/questions/9330802/zindex-on-clusters, http://stackoverflow.com/questions/6894548/positioning-markers-over-the-top-of-clusters- z-index-not-working – TMS