我试图在信息窗口中显示动态数据, 每当用户在地图上多边形上徘徊时都会在信息窗口中显示动态数据。 调试显示数据和其他信息窗口/ polygon 设置都很好 。 我能够在鼠标上看到颜色变化, 只是信息窗口没有出现。 背后的原因是什么? 我在这里缺少什么?
statePolygon = new google.maps.Polygon({
paths: stateBorderCoords,
strokeColor: #f33f00 ,
strokeOpacity: 1,
strokeWeight: 1,
fillColor: #ff0000 ,
fillOpacity: 0.2
});
statePolygon.pId = infoText; // Fetching from a JSON response
statePolygon.wPet = wPet; // Fetching from a JSON response
statePolygon.infoWindow = new google.maps.InfoWindow();
google.maps.event.addListener(statePolygon,"mouseover",function(event){
this.setOptions({fillColor: "#00FF00"});
this.infoWindow.setPosition(event.latLng);
this.infoWindow.setContent(this.wPet);
this.infoWindow.open(map, this);
});
google.maps.event.addListener(statePolygon,"mouseout",function(){
this.setOptions({fillColor: "#FF0000"});
this.infoWindow.close();
});
google.maps.event.addListener(statePolygon, click , function(){
//createInfoWindow(this.pId);
});
statePolygon.setMap(map);