2011-09-12 4 views
2

Google지도에서 사용자 정의 오버레이 아이콘 마커에 문제가 있습니다. 모든 줌 레벨에서 정상적으로 작동하지만 최대 줌에서 사라집니다. 데모에서는 아래쪽 아이콘 만 사라지지만 위쪽 아이콘은 괜찮습니다.Google지도 오버레이가 특정 확대/축소 수준에서 사라집니다.

데모 : http://random.hypervolume.com/map_bug.html

시도가 낮은 마커를 확대하기 위해, 34 번째 거리에 하나. 최대 줌 레벨에서는 사라집니다.

확인
var map; 

    function init() { 
    var opts = { zoom: 14, mapTypeId: google.maps.MapTypeId.ROADMAP }; 
    map = new google.maps.Map(document.getElementById('mapcanvas'), opts); 
    map.setCenter(new google.maps.LatLng(40.761231, -73.9839609)); 

    new MyMarker(new google.maps.LatLng(40.761231, -73.9839609), map, "A"); 
    new MyMarker(new google.maps.LatLng(40.75013, -73.987974), map, "B"); 
    } 

    var ICON_WIDTH = 52; 
    var ICON_HEIGHT = 52; 
    var ICON_URL = "http://random.hypervolume.com/m1.png"; 

    function MyMarker(position, map, id) { 
    this.id = id; 
    this.position = position; 
    this.map = map; 
    this.setMap(map); 
    } 

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

    MyMarker.prototype.onAdd = function() { 
    var div = this.div = document.createElement('DIV'); 
    div.id = this.id; 

    div.style.width = ICON_WIDTH; 
    div.style.height = ICON_HEIGHT; 
    div.style.position = 'absolute'; 

    var image = new Image(); 
    image.src = ICON_URL; 
    div.appendChild(image); 

    this.getPanes().overlayMouseTarget.appendChild(div); 
    }; 


    MyMarker.prototype.draw = function() { 
    var pos = this.getProjection().fromLatLngToDivPixel(this.position); 
    pos.x -= ICON_WIDTH/2; 
    pos.y -= ICON_HEIGHT/2; 
    this.div.style.top = pos.y + 'px'; 
    this.div.style.left = pos.x + 'px'; 
    }; 

답변

관련 문제