the code
GEvent.addDomListener(zz, "click", function()
{
alert("ddfd")
});
was executed normally,but event click was not triger
/////////////////////////////////////////
souce code
function Rectangle(bounds, opt_weight, opt_color) {
this.bounds_ = bounds;
this.weight_ = opt_weight || 20;
this.color_ = opt_color || "#888888";
this.fillcolor = "#FF0000";
}
Rectangle.prototype = new GOverlay();
Rectangle.prototype.initialize = function(map) {
var div = document.createElement("div");
div.style.border = this.weight_ + "px solid " + this.color_;
div.style.position = "absolute";
div.style.backgroundColor = this.fillcolor
map.getPane(G_MAP_MARKER_PANE).appendChild(div);
this.map_ = map;
this.div_ = div;
}
Rectangle.prototype.remove = function() {
this.div_.parentNode.removeChild(this.div_);
}
Rectangle.prototype.copy = function() {
return new Rectangle(this.bounds_, this.weight_, this.color_,
this.backgroundColor_, this.opacity_);
}
Rectangle.prototype.redraw = function(force) {
// We only need to redraw if the coordinate system has changed
if (!force) return;
var c1 = this.map_.fromLatLngToDivPixel(this.bounds_.getSouthWest
());
var c2 = this.map_.fromLatLngToDivPixel(this.bounds_.getNorthEast
());
this.div_.style.width = Math.abs(c2.x - c1.x) + "px";
this.div_.style.height = Math.abs(c2.y - c1.y) + "px";
this.div_.style.left = (Math.min(c2.x, c1.x) - this.weight_) +
"px";
this.div_.style.top = (Math.min(c2.y, c1.y) - this.weight_) +
"px";
}
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(39.917, 116.397), 14);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
var bounds = map.getBounds();
var southWest = bounds.getSouthWest();
var northEast = bounds.getNorthEast();
var lngDelta = (northEast.lng() - southWest.lng()) / 4;
var latDelta = (northEast.lat() - southWest.lat()) / 4;
var rectBounds = new GLatLngBounds(
new GLatLng(southWest.lat() + latDelta,
southWest.lng() + lngDelta),
new GLatLng(northEast.lat() - latDelta,
northEast.lng() - lngDelta));
var zz = new Rectangle(rectBounds)
map.addOverlay(zz);
GEvent.addDomListener(zz, "click", function()
{
alert("ddfd")
});
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---