I am facing a small issue.
When I am trying to open a info window on click of a custom overlay,
but Its not working. However same is working with marker. As far as I
know both extends MVC object but I am not able to find the cause of
problem.
....
...
....
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: 'HELLO'
});
var infowindow = new google.maps.InfoWindow({
'content': 'Hello Tomar'
});
Working code for marker->
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
Not Wroking for overlay ->
// USGSOverlay is custom overlay so overlay is coming on map -
copied sample code
var overlay = new USGSOverlay(bounds, srcImage, map);
// not able to add the listener for click event on overlay :(
google.maps.event.addListener(overlay, 'click', function() {
infowindow.open(map,overlay);
});
Would someone please suggest me to make this working?
var me = this;
google.maps.event.addDomListener([whatever element is used], "click",
function(ev) {
var e = ev||window.event;
google.maps.trigger(me, "click", e);
});
Actually I got the solution so for now I am marking this thread
closed.
Only silly mistake was there. Now its working fine.
Anyways Thanks for your help.
Dharmendra
On Dec 23 2009, 9:30 pm, Bob <gschneide...@gmail.com> wrote:
> Sorry, using this wouldn't work. Doing this in a customoverlaywould
> work:
>
> var me = this;
> google.maps.event.addDomListener([whatever element is used], "click",
> function(ev) {
> var e = ev||window.event;
> google.maps.trigger(me, "click", e);
>
> });
>
> On Dec 23, 8:28 am, Bob <gschneide...@gmail.com> wrote:
>
>
>
> > Is your customoverlaytriggering a 'click' event? Remember that a
> > mouse event is a DOM event and "addListener" only listens for custom
> > events. Basically you have to make sure your customoverlaylistens
> > for the DOM mouse event for whatever element youroverlayuses and
> > > // USGSOverlay is customoverlaysooverlayis coming on map -
> > > copied sample code
> > > varoverlay= new USGSOverlay(bounds, srcImage, map);
>
> > > // not able to add the listener for click event onoverlay:(