I found a solution for those like me that are a little strong-headed
and refuse to drop Prototype when they are implementing their
GoogleMap application.

First, there is no way to write something like

var MyPrettyOverlayClass = new Class.create(GOverlay, {
    // ...
});

It would be beautiful, but GOverlay is not a Prototype class and
cannot benefit from the Prototype's "extension" mechanism.

The trick I found is an ugly one, and I'm pretty sure that it would
raise some heated comments from my more experienced fellows around
here. The thing is, you could use Prototype to build a wrapper class.
More explicitly, that gives :

var MyUglyYetWorkingOverlayClass = new Class.create({
    initialize: function(your, params) {
      this._MUYWOverlayClass = function (y, p) {
        // the actual overlay constructor
      }
      this._MUYWOverlayClass.prototype = new google.maps.Overlay();
      this._MUYWOverlayClass.prototype.initialize = function(map) {
        // the actual initialization function
      }
      this._MUYWOverlayClass.prototype.redraw(force) {
        // ...
      }
      this._MUYWOverlayClass.prototype.copy() {
        // ...
      }
      this._MUYWOverlayClass.prototype.remove() {
        // ...
      }
      this._instance = new _this._MUYWOverlayClass(your, params);
    }
    redraw: function(force) {
      this._instance.redraw(force);
    }
    copy: function() {
      return this._instance.copy();
    }
    remove: function() {
      this._instance.remove();
    }
    /* see below */
    addTo: function(map) {
      map.addOverlay(this._intsance);
    }
    someOtherBusinessFunction: function() {
      //...
    }
});

There we are. We're able to build an overlay instance using the
prototype's classes above and benefit from the extension mechanism to
refine our overlays. Still, an issue occurs :

var o = new MyUglyYetWorkingOverlayClass(x, y);
map.addOverlay(o); // FAILS !!!

Indeed, the call to the addOverlay function would trigger a call to
the initialize() function of the passed instance. In our case, that
means the initialize function of the Prototype object, that is, its
constructor. Instead, we want to call the initialize() function of the
inner object. Thus, we can write :

map.addOverlay(o._instance); // Ugly but working

or in a more satisfying fashion

o.addTo(map);

It may not be the perfect solution, still it works. One of the benefit
is that I can define this class, among all my classes, before the load
of the google maps API.

On 12 nov, 16:42, Marcelo <[email protected]> wrote:
> On Nov 12, 1:57 pm, Antoine <[email protected]> wrote:
>
>
>
> > My question question was rather to know if there is a possibility to
> > use it for the very specific purpose I mentioned above, that is, to
> > implement the GOverlay interface. As far as I can see, the answer is
> > no, but maybe someone here has a workaround.
>
> I agree with Pil's answer.
> Personally, I wouldn't use libraries that I don't know what they are
> doing, and also, if you search the group, you'll find many previous
> posts about conflicts betweenPrototype.js and the 
> API:http://groups.google.com/group/google-maps-api/search?group=google-ma...
>
> For that reason, I would not expect many people here to be familiar
> enough withprototype.js to give you a definitive answer. Perhaps
> you'd have more luck in a forum dedicated toprototype, rather than to
> the Google Maps API.
>
> --
> Marcelo -http://maps.forum.nu
> --

--

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=.


Reply via email to