Tane, load your page in Firefox with Firebug enabled. Open the Firebug pane and click Script, then turn on Options/Break on All Errors. Now do your address lookup.
Firebug will stop on your line with the error. Look at what is displayed in the Watch window. Observe that "this" is the Window object. Not what you expected, is it? :-) You need to use a closure here. In your searchAddress function, save a reference to "this" in a local variable and then use that variable inside the geocoder callback function. Another comment or two: You are using the name "GMap2" to mean three different things! First is the GMap2 object that the Google Maps API defines. Second is your GMap2() plugin method in line 100. Third is the GMap2 property that you are adding to the DOM element in line 43. That's a bit confusing. Part of your code uses each() to iterate over the jQuery object, and part of it uses [0] assuming that there is only a single DOM element in the jQuery object. If you require an ID selector, e.g. $('#myMap') there will be only a single DOM element anyway, but it would probably be good to stick with one approach or the other for clarity. Also, I'm not sure why you create the jQuery.gmapp object for your functions and then assign them into the jQuery.fn object. Why not just assign them into jQuery.fn directly? Nothing wrong with the way you're doing it, it just seems like an unnecessary step. I didn't look at the code in more detail than that. Hope that helps! -Mike > From: Tane Piper > > I really need to try nail this plugin so I can move on to > other things in the project. This bit forms an important > part of my event system, and possibly other parts of my > application, but i'll also be releasing this code to the community. > > What I've done is, because the Geocoder will only be used in > this one method, I pass the Geocoder to the method, instead > of adding it to the jQuery object - so now that works. The > problem now is that when I try an locate an address I get the > error with the jQuery object: > > this[0] has no properties > > Now what I am doing is returning the this[0].GMap2 object, > which I do in another method. If i don't return it, I get no > error - but also nothing happens. > > The lastest version of the sourcecode is here: > http://pastebin.ca/615862 and the demo is still at > http://webrocket.ulmb.com/