How to extend Marker?

1,124 views
Skip to first unread message

Thai Dang Vu

unread,
Mar 11, 2010, 12:37:30 PM3/11/10
to google-map...@googlegroups.com
Hi Everybody,

Maybe this is a javascript question ... but I'm not sure.

I want to create a javascript class which extends the Marker class and which is able to store some more information. So I will have something similar to this

function MyClass(markerOptions, my_own_information) {
    // how to call the Marker's constructor?
}

MyClass.prototype = new Marker(... what will be here? ...)

Could anybody help me?

Thank you.

Peter Dang

unread,
Mar 11, 2010, 1:43:07 PM3/11/10
to google-map...@googlegroups.com

--
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 google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.



--
Hi,
 As you mean..you want to make the class with Marker?..as I know marker is a class and I think you can do as you mean. You can try...I think it is a good idea.
 
 

Thanks and Best Regards


Peter Dang
Professional Map team developer
------------------------------------------------------
Phone : +84 933 933 649
Axon Active Vietnam

Thai Dang Vu

unread,
Mar 11, 2010, 2:03:25 PM3/11/10
to google-map...@googlegroups.com
Hi,

You're in Vietnam, right? (your phone # tells me so). I want to try but I don't know how to write it correctly :)

If Marker is a java class, then I can do like this

public MyMarker extends Marker {
    private MyOwnInformation info;
    public MyMarker(MarkerOptions options, MyOwnInformation info) {
        super(options);
        this.info = info;
    }
}

Thai

Chad Killingsworth

unread,
Mar 11, 2010, 3:29:38 PM3/11/10
to Google Maps JavaScript API v3
I believe that most maps api objects are considered final and not
designed to be extended unless the documentation specifically states
otherwise (such as with OverlayView and MVCObject).

You can either implement your own marker object as a custom overlay,
or add additional prototypes to the provided Marker object (making
sure not to conflict with any current prototypes).

Chad Killingsworth

On Mar 11, 1:03 pm, Thai Dang Vu <tdan...@gmail.com> wrote:
> Hi,
>
> You're in Vietnam, right? (your phone # tells me so). I want to try but I
> don't know how to write it correctly :)
>
> If Marker is a java class, then I can do like this
>
> public MyMarker extends Marker {
>     private MyOwnInformation info;
>     public MyMarker(MarkerOptions options, MyOwnInformation info) {
>         super(options);
>         this.info = info;
>     }
>
> }
>
> Thai
>

> On Thu, Mar 11, 2010 at 1:43 PM, Peter Dang <phucdaid...@gmail.com> wrote:


>
> > On Fri, Mar 12, 2010 at 12:37 AM, Thai Dang Vu <tdan...@gmail.com> wrote:
>
> >> Hi Everybody,
>
> >> Maybe this is a javascript question ... but I'm not sure.
>
> >> I want to create a javascript class which extends the Marker class and
> >> which is able to store some more information. So I will have something
> >> similar to this
>
> >> function MyClass(markerOptions, my_own_information) {
> >>     // how to call the Marker's constructor?
> >> }
>
> >> MyClass.prototype = new Marker(... what will be here? ...)
>
> >> Could anybody help me?
>
> >> Thank you.
>
> >> --
> >> 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
> >> google-map...@googlegroups.com.
> >> To unsubscribe from this group, send email to

> >> google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2Bunsu...@googlegroups.com>


> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> > --
> > Hi,
> >  As you mean..you want to make the class with Marker?..as I know marker is
> > a class and I think you can do as you mean. You can try...I think it is a
> > good idea.
>
> > Thanks and Best Regards
>
> > Peter Dang
> > Professional Map team developer
> > ------------------------------------------------------
> > Phone : +84 933 933 649
> > Axon Active Vietnam
>
> > --
> > 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
> > google-map...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2Bunsu...@googlegroups.com>

Thai Dang Vu

unread,
Mar 11, 2010, 3:38:31 PM3/11/10
to google-map...@googlegroups.com
Thank you Chad.

" ... or add additional prototypes to the provided Marker object ...": that's what I just did.

I come to javascript from Java so I thought of extending and implementing and forgot about the prototype thing.

To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages