2011-11-22 108 views
1

我在地圖上添加了瓷磚。我現在想要的是:在地圖上點擊,我想改變點擊的圖塊的背景顏色。我該如何解決這個問題?它甚至有可能嗎?在Google地圖上更改瓷磚的背景顏色

我已經使用的代碼,以瓷磚添加到我的地圖(從谷歌地圖API V3):

<script> 

    function CoordMapType(tileSize) { 
    this.tileSize = tileSize; 
    } 

    CoordMapType.prototype.getTile = function(coord, zoom, ownerDocument) { 
    var div = ownerDocument.createElement('DIV'); 
    div.style.width = this.tileSize.width + 'px'; 
    div.style.height = this.tileSize.height + 'px'; 
    div.style.fontSize = '10'; 
    div.style.borderStyle = 'solid'; 
    div.style.borderWidth = '1px'; 
    div.style.borderColor = '#AAAAAA'; 
    return div; 
    }; 

    var map; 
    var chicago = new google.maps.LatLng(41.850033,-87.6500523); 

    function initialize() { 
    var mapOptions = { 
     zoom: 10, 
     center: chicago, 
     mapTypeId: google.maps.MapTypeId.ROADMAP 
    }; 
    map = new google.maps.Map(document.getElementById("map"), 
             mapOptions); 

    // Insert this overlay map type as the first overlay map type at 
    // position 0. Note that all overlay map types appear on top of 
    // their parent base map. 
    map.overlayMapTypes.insertAt(
     0, new CoordMapType(new google.maps.Size(256, 256))); 
    } 
</script> 

回答