2011-09-12 3 views
2

Googleマップのカスタムオーバーレイアイコンマーカーに問題があります。 すべてのズームレベルで正常に動作しますが、最大ズームでは消えます。デモでは下のアイコンだけが消えますが、上のアイコンはOKです。Googleマップオーバーレイが特定のズームレベルで消える

デモ:http://random.hypervolume.com/map_bug.html

は下のマーカー、34番目の通りに1をズームインしてください。最大ズームレベルで消えます。ここで

がソースである:

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'; 
    }; 

答えて

関連する問題