Martin wrote:
> Take a look at how Mike Williams has extended the GPolygon() and
> GPolyline() objects with his EPoly extension:
> 
> http://econym.org.uk/gmap/epoly.htm
> 

I saw that. It's not what I'm talking about.
Basically, I could write a simple function that takes GLatLng and radius 
and returns array of vertices that I can use to create a GPolygon. Or I 
could add some extra prototype methods to GOplygon. I could also write a 
  new class that aggregates a polygon and implements GOverlay interface. 
But all of these aren't what I'm looking for.
my goal is to understand how properly it should be done with their api 
(and nobody from google seems to be able to answer this questions 
themselves) to *inherit* from GPolygon.

the following code should work as is:

var circle = new GCircle(point, radius);
map.addOverlay(circle);


THe case of aggregation and implementing GOverlay interfaces seems to be 
cleanest approach, but in this case circle instanceof GPolygon is not 
true anymore. Moreover, you cannot add event handlers to the circle like 
I could add event handlers to regular polygons.


> You could take a similar approach and create new prototype methods of
> GPolygon() where required.
> 
> Or look at his ELabel extension:
> 
> http://econym.org.uk/gmap/elabel.htm
> 
> ELabel is a custom GOverlay() and as GPolygons and GPolylines are
> GOverlays too you might find looking at the ELabel source code will
> help you create the 'initialize()' method for your GCircle().
> 
> Also look at the other prototype methods of ELabel - you'll be able to
> see what (other) new prototype methods you must define for GCircle().
> ('supportsHide' looks like is required for example).
> 

As I said in one of my posts I was able to do it in way, but I really 
would like to see reply from some google devs who designed all that 
stuff; what can they say about inheritance of their classes

basically, after trying all types of code from different discussions 
related to inheritance in Javascript I had to do something on my own 
because NOTHING works for GPolygon.

GCircle.prototype = new GPolygon doesn't work.
The only way I made it work (which isn't true inheritance by the way) is 
this:

function GCircle(latlon, radius){
        ...
        GPolygon.call(this, ... ... ...);
        this.whatever = blahblahblah;
}

GCircle.prototype = GPolygon.prototype;

that's the only way I could make it work. Why it's not full inheritance: 
if I want to override initialize() interface of GOverlay I have to do this:

GCircle.prototype.initialize = function(map){
        do something...
        call initialize of parent class (GPolygon::initialize)
}

The problem is that GCircle.prototype = GPolygon.prototype and that way 
to modify initialize() means that GPolygon initialize will also be modified!

Overall, my impression is that all the GPolygon and the other stuff 
aren't user friendly if it comes to customization and inheritance. All 
it can be used for is dump creation and ... that's it. No usefull 
methods like moving etc.



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