In these project http://tools.webmasterei.com/countrymap/ the
polygones are added via ajax in a global array polygones[]:

After adding the polygone I like to detect clicks like in the app from
Mike W. (inside)

Here is the snippet:
==
var map;
var polygons = [];
var countries = Array();

var rules= {
        '.country input' : function(el) {
                el.onchange = function() {
                        var id = el.id.split('_');
                        new Ajax.Request('./kml.class.php?countryid=' + id[1] + 
'&checked='
+ el.checked, {
                                        method: 'get',
                                        onSuccess: function(transport) {
                                                 eval(transport.responseText);
                                        }
                                        });
                }
        }
};

Event.observe(window, 'load', init_app);
Event.observe(window, 'unload', GUnload);

function init_app(event) {
  Behaviour.register(rules);
  Behaviour.apply(rules);
  map = new GMap2(document.getElementById("map"));
  map.setCenter(new GLatLng(15.507563, 10.797715), 2);
  GEvent.addListener(map, "click", function(overlay,point) {
        if (!overlay) {
          for (var i=0; i<polygons.length; i++) {
                if (polygons[i].Contains(point)) {
                  map.openInfoWindowHtml(point,"You clicked on ");
                  //i = 999; // Jump out of loop
                }
          }
        }
  });
}
==
In the callback appears after adding of one polygone the error
'olygons[i] is undefined'.

Any ideas?

Rainer


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