在谷歌地图上更改图块的背景颜色

时间:2011-11-22 20:53:48

标签: javascript google-maps google-maps-api-3

我在地图上添加了瓷砖。我现在想要的是:在地图上点击,我想改变点击的瓷砖的背景颜色。我怎么做到这一点?它甚至可能吗?

我使用的代码,为了向我的地图添加切片(来自google maps 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>

1 个答案:

答案 0 :(得分:0)

如果您使用的是版本3,则可以执行此操作 - http://code.google.com/p/google-maps-utility-library-v3/wiki/Libraries