[EMAIL PROTECTED] wrote:
> On Oct 13, 8:33 am, ramasaig <[EMAIL PROTECTED]> wrote:
>> On Oct 13, 4:08 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
>> wrote:
>>
>>
>>
>>> On Oct 13, 7:46 am, Mike Williams <[EMAIL PROTECTED]> wrote:
>>>> You could write something like this
>>>> GEvent.addListener(map, 'click', function(overlay, latlng) {
>>>>   if (overlay) {
>>>>     if (overlay instanceof GPolygon) {
>>>>       if (overlay.isHidden()) {
>>>>         overlay.show();
>>>>       } else {
>>>>         overlay.hide();
>>>>       }
>>>>     }
>>>>   }
>>>> });
>>> Does clicking on a hidden overlay work?
>>> I would have thought that would work for hiding the overlays, but not
>>> for showing them again.
>>>    -- Larry
>> You are right, it does hide the overlays, but won't show them again.
>> The click is detected, but 'if (overlay)' is now false (because it's
>> hidden, I assume ?).
>>
>> This is only my second day on Google maps (though I've used JS
>> before), and I'm confused because I understood GPolygon had been made
>> clickable recently (v. 2.88). I had therefore expected something like:
>>
>> GEvent.addListener(polygon, 'click', function(arguments) {....
>> would work, but clearly not.
>>
>> You say I must _use_ the arguments.  OK, but I'm not sure how, other
>> than in the function.  I'll add 'overlaylatlng' as well
>> I'll try Mike Williams' script too.
> 
> Try this (make your map variable and your polygon variables global):
> GEvent.addListener(map, 'click', function(overlay, latlng,
> overlaylatlng) {
> // GLog.write("map click ("+overlay+","+latlng+","+overlaylatlng+")");
>   if (overlay) {
>     if (overlay instanceof GPolygon) {
>       if (overlay.isHidden()) {
>         overlay.show();
>       } else {
>         overlay.hide();
>       }
>     }
>   } else if (latlng) {
>   if (polyNW.Contains(latlng)) {polyNW.show();}
>   if (polyCT.Contains(latlng)) {polyCT.show();}
>   if (polySE.Contains(latlng)) {polySE.show();}
>   if (polySW.Contains(latlng)) {polySW.show();}
>   }
> });
> 
> The overlaylatlng argument is undefined sometimes, I don't understand
> why.  I though it was supposed to _always_ return a valid value.
> 
>   -- Larry

Thanks.  I'll try that and let you know what happens.

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