Javascript 更改谷歌地图上互动程序的背景颜色
我已经在我的地图上添加了瓷砖。我现在想要的是:在地图上点击,我想改变点击的瓷砖的背景颜色。我怎么才能做到呢?有可能吗 为了向我的地图添加平铺,我使用的代码是(来自google maps api v3):Javascript 更改谷歌地图上互动程序的背景颜色,javascript,google-maps,google-maps-api-3,Javascript,Google Maps,Google Maps Api 3,我已经在我的地图上添加了瓷砖。我现在想要的是:在地图上点击,我想改变点击的瓷砖的背景颜色。我怎么才能做到呢?有可能吗 为了向我的地图添加平铺,我使用的代码是(来自google maps api v3): 函数CoordMapType(tileSize){ this.tileSize=tileSize; } CoordMapType.prototype.getTile=函数(坐标、缩放、所有者文档){ var div=ownerDocument.createElement('div'); div
函数CoordMapType(tileSize){
this.tileSize=tileSize;
}
CoordMapType.prototype.getTile=函数(坐标、缩放、所有者文档){
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';
返回div;
};
var映射;
var chicago=new google.maps.LatLng(41.850033,-87.6500523);
函数初始化(){
变量映射选项={
缩放:10,
中心:芝加哥,
mapTypeId:google.maps.mapTypeId.ROADMAP
};
map=new google.maps.map(document.getElementById(“map”),
地图选项);
//将此覆盖贴图类型作为第一个覆盖贴图类型插入
//位置0。请注意,所有覆盖贴图类型都显示在
//它们的父基地图。
map.overlymaptypes.insertAt(
0,新的CoordMapType(新的google.maps.Size(256256));
}
如果您使用的是版本3,则可以执行以下操作-
<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>