Make the Wrapper object listen to the GM object and retrigger all events on
the Wrapper.  For example:

function Shape() {
  this.shape_ = new google.maps.Polygon(...);
  var self = this;
  google.maps.event.addListener(
      this.shape_, 'click', function(e) {
    google.maps.event.trigger(self, 'click', e);
  });
  ...
}

- Ben

Android brevity.
On 30 Oct 2010 23:53, "Andre Tannus" <[email protected]> wrote:
> Hi guys, this is my first post.
>
>
> I'm relatively new to javascript.
>
>
> I'm designing a javascript interface in JS, and I'm using a lot of
> Google Maps (henceforth GM) in it; My tackles at it might sound
> confusing, because I am somewhat confused, so please, bare with me.
>
>
> In my app, I decided to wrap the GM objects inside my own. For
> instance, I have a "shape" object which aggregates either a polyline or
> a polygon object - for the sake of simplicity, let's go with polygon,
> so, for a very simplified example to my problem.
>
>
> // My Polygon "class"
> myPolyClass = function(map) {
> this.path = [];
> this.map = map;
> this.poly = new google.maps.Polygon({ /*config*/|});
>
> this.setPath = function(path) {
> this.poly.setPaths(path);
> }
>
>
> google.maps.event.addListener(this.poly, 'click', function (event) {
> clickedInstance = this;
> clickedInstance.setPath([]);
> });
>
>
> }
>
>
> // myPoly instance
> myPoly = new myPolyClass(map);
>
>
> The problem is handling events on the polygon. When I click the polygon
> on the map, (which in this example makes it go away), the GM Polygon
> object fires the event (not my wrapper intance!).
>
>
> The question: How to I bubble the event outwards, when the GM object
> isn't aware that it is within a wrapper?
>
>
> I see two ways around it:
>
>
> 1. Make the app aware of the wrapper-object relationship. That would
> require creating a registry like object, that knows which of my objects
> own which GM object. Then the GM object fires a custom event that the
> registry is listening to, and the registry triggers the appropriate
> wrapper event.
>
>
> 2. Make the GM object aware of the Wrapper object, and trigger it
> directly. Well, in that case, I could just go on and USE the GM object
> directly, and append my custom properties to it (which is precisely
> what I'm trying to avoid)
>
>
> 3.
> _______________________________________________________________________
>
>
> eventually 4. ____, 5. ______
>
>
> I hope you guys can shine light on my troubled mind.
>
>
> thank you in advance,
>
>
> André
>
> --
> You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
> To post to this group, send email to
[email protected].
> To unsubscribe from this group, send email to
[email protected]<google-maps-js-api-v3%[email protected]>
.
> For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" 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-js-api-v3?hl=en.

Reply via email to