On Oct 13, 7:18 am, ramasaig <[EMAIL PROTECTED]> wrote:
> On Oct 13, 2:17 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > On Oct 13, 4:34 am, ramasaig <[EMAIL PROTECTED]> wrote:> I have four 
> > polygons on my map.  I want to be able to make each appear/
> > > disappear separately when I click in the area of the required
> > > polygon.  So far I have only managed to attach an EventListener to the
> > > 'map' object, and at the moment one polygon responds to a click
> > > anywhere on the map (and duly hides and reappears).  See example,
> > > click map for the red polygon to appear:
>
> > >http://www.holidaymullandiona.co.uk/maps/firstmap.html
>
> > > How do I make the individual polygons respond to a click, please ?
>
> > You probably want to use the arguments of the map "click" 
> > listener:http://code.google.com/apis/maps/documentation/reference.html#GMap2.E...
>
> Thanks, I'm sure you're right, I have read that several times already,
> but I'm not understanding something correctly.
> I have:
>
> GEvent.addListener(map, 'click', function(overlay, latlng) {
>         if (polyNW.isHidden()) {
>                 polyNW.show();
>         } else {
>                 polyNW.hide();
>         }
>
> });
>
> This alternately shows/hides the polygon if I click anywhere on the
> map.  It's the bit of making it work only if I click in 'polyNW' that
> I don't get.  I've tried several variants, but no joy so far.

You need to _use_ the arguments (btw - I would suggest using the third
parameter, the overlaylatlng, as the other two are optional, one is
null, the other has a value, depending on where the click is)
Combined with the .Contains() method in Mike Williams' epoly
extension:
http://econym.org.uk/gmap/epoly.htm

Should allow you to detect when you have clicked on the polygon.

  -- Larry

>
> Tim
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to