Google maps google maps V3中的openInfoWindowHtml和GPolygon是什么
GPolyline和GPolygon的v3等价物为。这两个都有可以侦听的单击事件 更棒的是,谷歌提供了,包括。此外,v3 API中没有Google maps google maps V3中的openInfoWindowHtml和GPolygon是什么,google-maps,google-maps-api-3,Google Maps,Google Maps Api 3,GPolyline和GPolygon的v3等价物为。这两个都有可以侦听的单击事件 更棒的是,谷歌提供了,包括。此外,v3 API中没有openInfoWindowHtml()方法。您必须创建一个对象,在该对象上可以调用open()或close()方法。如果同时只想看到一个对象,通常只需要一个InfoWindow对象: var polygon = new GPolygon(polylines[0],"#FFFFFF", 1, 1.0, color,opacity); polygon.h
openInfoWindowHtml()
方法。您必须创建一个对象,在该对象上可以调用open()
或close()
方法。如果同时只想看到一个对象,通常只需要一个InfoWindow
对象:
var polygon = new GPolygon(polylines[0],"#FFFFFF", 1, 1.0, color,opacity);
polygon.hid = this.id;
polygon.heat = this.heat;
google.maps.event.addListener(polygon, 'click', function(point) {
HoodsUnselect(active_hood_id);
active_hood_id = polygon.hid;
polygon.setOptions({fillColor: '#2948e4', fillOpacity: 0.50 });
//polygon.setFillStyle( { color:'#2948e4',opacity:'0.50' } );
if (point) {
map.openInfoWindowHtml(point, the_list); // open info window where user clicked
} else {
map.openInfoWindowHtml(polygon.getBounds().getCenter(), the_list); // open info window at the center of polygon
}
});
在信息窗口方面,v2api和v3api的主要区别在于,在v3api中,可以同时打开多个信息窗口。这在v2 API中是不可能的。要打开多个信息窗口,您需要创建多个InfoWindow
对象,而不是为所有标记(覆盖)创建一个对象
对于多边形,以下是如何在v3 API中创建多边形(从示例中借用):
您的代码中应该有问题,我使用的是v3,infoWindow.open获取两个参数:
infoWindow.open=function(a,b){this.set(“anchor”,b);this.set(“map”,a)}
@Mehdi Karamosly:第二个参数是可选的。如果通过,它将是弹出信息窗口的标记。如果未指定,它将仅显示在某个默认位置(左上角)。()
var infoWindow = new google.maps.InfoWindow();
google.maps.event.addListener(yourOverlay, 'click', function () {
infoWindow.setContent('Some info on yourOverlay');
infoWindow.open(map);
});
var bermudaTriangle = new google.maps.Polygon({
paths: [
new google.maps.LatLng(25.774252, -80.190262),
new google.maps.LatLng(18.466465, -66.118292),
new google.maps.LatLng(32.321384, -64.75737)
],
strokeColor: "#FF0000",
strokeOpacity: 0.8,
strokeWeight: 3,
fillColor: "#FF0000",
fillOpacity: 0.35
});
bermudaTriangle.setMap(map);