Hi,

I'm developping a Google Maps application using the Prototype.js
library, as well for Ajax communication handling as for implementing
my business classes. I've acheived a rather clean code that works
pretty well, but now I need to add custom overlays.

So I'm wondering if there is a way of extending the GOverlay interface
using the Prototype.js classes. It would be neater than the solution I
use for now, that is, the solution shown in the official
documentation.

More precisely, there is my current code :

_ServicesOverlay = function (location)
{
  this._location = location;
  location.marker.sol = this;
  this._container = new Element('div');
}
_ServicesOverlay.prototype = new google.maps.Overlay();

_ServicesOverlay.prototype.initialize = function (map)
{
  this._container.style.display = 'none';
  map.getPane(G_MAP_MARKER_PANE).appendChild(this._container);
  this._map = map; // saves back reference
}

_ServicesOverlay.prototype.redraw = function (force)
{
  -- CUT --
}

_ServicesOverlay.prototype.remove = function ()
{
  this._container.parentNode.remove(this._container);
}

_ServicesOverlay.prototype.copy = function ()
{
  return new ServiceOverlay(this._location);
}

_ServicesOverlay.prototype.filter = function (filter)
{
  -- CUT --
  this.redraw(true);
}

It's working fine, but it integrates poorly with my code, as I've to
put this in the middle of an init function. Instead, I'd like to
obtain something like this :

_ServiceOverlay = Class.create(google.maps.Overlay, {
                initialize: function (map)
                {
                        //...
                },
                redraw: function (force)
                {
                        //...
                },
                copy: function ()
                {
                        //...
                },
                remove: function ()
                {
                        //...
                },
                filter: function (filter)
                {
                        //...
                }
});

It would be a lot cleaner, but I've a problem with the initialize()
function, as it stands as the constructor for Prototype's classes,
while being the initalization function called by the Google Maps
library. Do you know a way to use Prototype there or should I forget
it definitely ?

--

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