2011-11-22 48 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> 

回答